Annoying NoMethodError in Admin/project#show when I try to edit and save
a project and view a project by clicking on <%= link_to c.title,
{:action => ''show'', :id => c.id} -%>
Showing app/views/admin/project/show.rhtml where line #7 raised:
undefined method `feature'' for #<Project:0x31eb290>
Extracted source (around line #7):
4: <strong>Title: </strong> <%= @project.title %><br />
5: <strong>Date Created:</strong> <%= @project.created_at
%><br />
6: <strong>Last updated:</strong> <%= @project.updated_at %>
7: <strong>Features: </strong> <%= link_to @project.feature.name,
:action => "show_feature", :id => @project.features.id
%><br />
8: </p>
9:
10: <p><%= @project.description %></p>
heres the show.rhtml:
<h1><%= @project.title %></h1>
<p><strong>Price: </strong> £<%= @project.price %><br
/>
<strong>Title: </strong> <%= @project.title %><br />
<strong>Date Created:</strong> <%= @project.created_at
%><br />
<strong>Last updated:</strong> <%= @project.updated_at %>
<strong>Features: </strong> <%= link_to @project.feature.name,
:action
=> "show_feature", :id => @project.features.id %><br />
</p>
<p><%= @project.description %></p>
<hr />
<p>Developer <%= mail_to @project.employee_id -%></p>
<p>Designer <%= mail_to @project.employee_id -%></p>
<%= link_to ''Back'', {:action =>
''list''} %>
heres the project_controller.rb:
def index
render :action => ''list''
end
def new
@project = Project.new
@features = Feature.find(:all)
end
def create
@project = Project.new(params[:project])
if @project.save
redirect_to :action => ''list''
else
render :action => ''new''
end
end
def list
@projects = Project.find(:all)
end
def show
@project = Project.find(params[:id])
end
def edit
@project = Project.find(params[:id])
@features = Feature.find(:all)
end
def update
@project = Project.find(params[:id])
@features = Feature.find(:all)
if @project.update_attributes(params[:project])
redirect_to :action => ''show'', :id => @project
else
render :action => ''edit''
end
end
def delete
Project.find(params[:id]).destroy
redirect_to :action => ''list''
end
def show_feature
@feature = Feature.find(params[:id])
end
--
Posted via http://www.ruby-forum.com/.
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Ruby on Rails: Talk" group.
To post to this group, send email to
rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org
To unsubscribe from this group, send email to
rubyonrails-talk-unsubscribe@googlegroups.com
For more options, visit this group at
http://groups.google.com/group/rubyonrails-talk?hl=en
-~----------~----~----~----~------~----~------~--~---