Women in Technology

Hear us Roar



Article:
  Rolling with Ruby on Rails, Part 2
Subject:   I'm stuck on the create method
Date:   2006-01-22 15:43:15
From:   H2Oman
When I include this


def create
@recipe = Recipe.new(@params['recipe'])
@recipe.date = Date.today
if @recipe.save
redirect_to :action => 'list'
else
render_action 'new'
end
end


I get this error when I go to url.../new
" SyntaxError in <controller not set>#<action not set>"
"app/controllers/recipe_controller.rb:19: formal argument cannot be an instance variable"


This error occures on all the pages; list, edit, ect. If I remove the create method then the error goes away.



Full Threads Oldest First

Showing messages 1 through 4 of 4.

  • I'm stuck on the create method
    2006-10-20 13:09:49  asmasif [View]

    Actually one "end" is missing after the if-else block. That is why the "Create" method is not working. Put an extra "end" after the if-else and before the def-end.
  • Curt Hibbs photo I'm stuck on the create method
    2006-01-22 18:24:49  Curt Hibbs | O'Reilly AuthorO'Reilly Blogger [View]

    Ruby is saying that there is a syntax error on line 19, so they entire controller is not getting used.

    What's on line 19?
    • I'm stuck on the create method
      2006-01-23 00:17:20  H2Oman [View]

      The beginning of the create method... I have checked and rechecked this block of code but I can't find a mistake... I have also copy and pasted the provided at the beginning of the article. I've only been playing with ruby for about a month and this is my first time trying rails, although I have read throught the article before. I think I may just work through the tutorial again...starting from scratch and see if I have better luck... but I would like to know what I might have done wrong.

      I'm am using "locomotive" to run rails with these specs:
      Ruby version 1.8.2 (powerpc-darwin7.9.0)
      RubyGems version 0.8.11
      Rails version 1.0.0
      Active Record version 1.13.2
      Action Pack version 1.11.2
      Action Web Service version 1.0.0
      Action Mailer version 1.1.5
      Active Support version 1.2.5
      Application root /Users/chris/Desktop/cookbook
      Environment development
      Database adapter mysql

      • Curt Hibbs photo I'm stuck on the create method
        2006-01-23 04:10:23  Curt Hibbs | O'Reilly AuthorO'Reilly Blogger [View]

        You could download Instant Rails:

        http://instantrails.rubyforge.org/

        It contains this cookbook app as one of its preinstalled sample applications. There you'll find the complete, working source code and you can compare that code with yours.

        Curt