Hello! At first sorry for my English! I am having problem with a show and update view. I have two tables in my database named: "candidates" and "provincias". Candidates has a int column named 'provincia' which is related with int column 'id' on the table "provincias". I am using nifty:generators for authentication, and the 'id' of the user is related with Candidates int column named 'candidateid'. I have the two models: *Model candidate.rb*/ class Candidate < ActiveRecord::Base belongs_to :provincia end/ *Model provincia.rb* /class Provincia < ActiveRecord::Base has_many :candidates end/ And my controller: *Controller candidates.controller.rb* /class CandidatesController < ApplicationController def list = Candidate.find(:all) end def show = Candidate.find_by_candidateid(params[:id]) if .blank? redirect_to :controller => "candidates", :action => "new" end end def new = Candidate.new @userid = session[:user_id] = Provincia.find(:all) end def create = Candidate.new(params[:candidate]) if .save redirect_to :action => 'show' else render :action => 'new' end end def edit = Candidate.find(params[:id]) @userid = session[:user_id] = Provincia.find(:all) end def update = Candidate.find(params[:id]) if .update_attributes(params[:candidate]) redirect_to :action => 'show', :id => else render :action => 'edit' end end def show_provincias = Provincia.find(params[:id]) end end/ When I try to see the show view I have this error: |undefined method `name' for nil:NilClass| *View show.html.erb* /<%= .name %> <%= .surname %>
DNI: | <%= .dni %> |
Email : | <%= .email %> |
Phone: | <%= .phone %> |
City: | <%= .city %> |
State: | <%= .provincia.name %> |
Changing your data
: | <%= text_field 'candidate', 'name' %> |
: | <%= text_field 'candidate', 'surname' %> |
: | <%= text_field 'candidate', 'email' %> |
: | <%= text_field 'candidate', 'phone' %> |
: | <%= text_field 'candidate', 'city' %> |
: | <%= collection_select(:candidate,:,:id,:name) %> |