On 5.10.2005, at 19.38, Robert Boone wrote:
> I have an action that is used for first render and is recalled on
> post. On first render it works fine, but when the view is re-
> posted to
> it cannot find my instance variable ''ie. @adhesive''.
>
> This is the error I get:
> undefined method `cost'' for nil:NilClass
> <p><%= number_to_currency @adhesive.cost %> permit</p>
Robert,
I don''t exactly know what the reason is, but the above indicates that
you''re rendering an rhtml view. However, the code inside "if
request.post?" never renders a template (it only uses render with
the :text parameter), so it looks to me like that code is never
executed. So could you post both the template you''re using with the
action and the whole error, including the file where it came from?
Then it''s a tad easier to see what''s going on.
//jarkko
>
> The code in question is below.
>
> def type
>
> person = session[:person]
> @permit = Permit.new
>
> @adhesive = Price.adhesive(person.status,person.semester)
> @carpool = Price.carpool(person.status,person.semester)
> @extra = Price.extra(person.semester)
>
> @mccaslin = person.mccaslin?
>
> if request.post?
> person = session[:person]
> person.campus = params[:campus]
> person.permit = Permit.new(params[:permit])
>
> if person.save
> render :text => "WORKED"
> else
> flash[:notice] = "There was a problem with your submission.
> Please try again."
> render :text => "FAILED"
> end
> end
> end
>
> Thanks,
> Robert
> _______________________________________________
> Rails mailing list
> Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
> http://lists.rubyonrails.org/mailman/listinfo/rails
>
>
--
Jarkko Laine
http://jlaine.net
http://odesign.fi
_______________________________________________
Rails mailing list
Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails