Thursday, 3 July 2014

Amazing ActiveResource

#Create a new Blog
#rails g Blog
#rails g scaffold Post title body:text
#Using Basic auth
class ApplicationController < ActionController::Base
http_basic_authenticate_with name: "test", password: "test"
end
#rails s
#from console
#2.1-head :039 > require 'active_resource'
#true
class Post < ActiveResource::Base
self.site = "http://test:test@localhost:3000"
end
#2.1-head :036 >post = Post.new
#2.1-head :036 >post.title = "works?"
#2.1-head :036 >post.save
#=> true
view raw gistfile1.rb hosted with ❤ by GitHub

No comments:

Post a Comment