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: Title: <%= @project.title %>
5: Date Created: <%= @project.created_at %>
6: Last updated: <%= @project.updated_at %>
7: Features: <%= link_to @project.feature.name,
:action => “show_feature”, :id => @project.features.id %>
8:
9:
10:
<%= @project.description %>
heres the show.rhtml:
<%= @project.title %>
Price: £<%= @project.price %>
Title: <%= @project.title %>
Date Created: <%= @project.created_at %>
Last updated: <%= @project.updated_at %>
Features: <%= link_to @project.feature.name, :action
=> "show_feature", :id => @project.features.id %>
<%= @project.description %>
Developer <%= mail_to @project.employee_id -%>
Designer <%= mail_to @project.employee_id -%>
<%= 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