class User << ActiveRecord::Base
has_many :pages
end
class Page << ActiveRecord::Base
belongs_to :user
end
make sure your Page model has the attribute :email_of_creator (or whatever you choose)
app/controllers/page_controller.rb:
def new
@page = Page.new
@page.email_of_creator = current_user.email
end
def create
@page = Page.new(params[:page])
end
app/views/page/new.html.erb:
<%= form_for @page do |f| %>
<%= f.hidden_field :email_of_creator %>
<%= other fields the user must enter ... %>
<% end %>
app/controllers/page_controller.rb:
def index
@pages = Page.all()
end
app/views/pages/index.html.erb:
<% @pages.each do |p| %>
<%= "created by #{p.email_of_creator}" %>
<% end %>
Joe got a job, on the day shift, at the Utility Muffin Research Kitchen, arrogantly twisting the sterile canvas snout of a fully charged icing anointment utensil.