More Related Content
Similar to Pluginが広げるRailsの魅力
Similar to Pluginが広げるRailsの魅力 (20)
More from Yoji Shidara (17)
Pluginが広げるRailsの魅力
- 36. class ApplicationController
include AuthenticatedSystem
before_filter :login_from_cookie
class MyController < ApplicationController
before_filter :login_required
before_filter :login_required, :only =>[:edit, :update]
- 37. <h3>Welcome user</h3>
<% if logged_in? %>
<p>
Welcome, <%=h self.current_user.login %>
</p>
<% else %>
<!-- login form goes here -->
<% end %>
- 45. class Post < ActiveRecord::Base
acts_as_taggable
belongs_to :user
end
p = Post.find(:first)
p.tag_list.to_s # quot;quot;
p.tag_list = quot;Funny, Sillyquot;
p.save
p.reload.tag_list.to_s # quot;Funny, Sillyquot;
p.tag_list.add(quot;Greatquot;, quot;Awfulquot;)
p.tag_list.remove(quot;Funnyquot;)
- 48. class ActsAsTaggableMigration < ActiveRecord::Migration
def self.up
create_table :tags do |t|
t.column :name, :string
end
create_table :taggings do |t|
t.column :tag_id, :integer
t.column :taggable_id, :integer
t.column :taggable_type, :string
t.column :created_at, :datetime
end
add_index :taggings, :tag_id
add_index :taggings, [:taggable_id, :taggable_type]
end
- 56. lang=ko
lang=ja
msgid quot;messagequot;
msgstr quot; quot;
msgid quot;Message|Textquot;
msgstr quot; quot;