This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
```ruby | |
1.9.3p194 :006 > Twitter.configure do |config| | |
1.9.3p194 :007 > config.consumer_key = PROVIDER['twitter']['key'] | |
1.9.3p194 :008?> config.consumer_secret = PROVIDER['twitter']['secret'] | |
1.9.3p194 :009?> config.oauth_token = PROVIDER['twitter']['oauth_token'] | |
1.9.3p194 :010?> config.oauth_token_secret = PROVIDER['twitter']['oauth_token_secret'] | |
1.9.3p194 :011?> end | |
1.9.3p194 :012 > Twitter.user_search('rays') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Rails.configuration.middleware.insert_after(::Rack::Lock, "::Rack::Auth::Basic", "Not for public eyes") do |u, p| | |
u == 'foo' && p == 'bar' | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
params[:user] = {:name => 'Foo',:email => '[email protected]'} | |
@user = User.new(params[:user]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@user = User.update_attributes(params[:user]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Account < ActiveRecord::Base | |
has_many :rooms | |
accepts_nested_attributes_for :rooms | |
end | |
class Room < ActiveRecord::Base | |
belongs_to :account | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User < ActiveRecord::Base | |
attr_protected :admin | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class User < ActiveRecord::Base | |
attr_accessible :name | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BooksController < ApplicationController | |
def create | |
@book = Book.new(params[:book], as : user_role) | |
respond_to do |format| | |
if @book.save | |
format.html { redirect_to @book notice 'Book was successfully created.' } | |
else | |
format.html { render action : "new" } | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Book < ActiveRecord::Base | |
attr_accessible :name, :public, :author | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class Book < ActiveRecord::Base | |
attr_accessible :name, :author, :public as : :admin | |
attr_accessible :name, :author, as : :user | |
end |
OlderNewer