Not signed in (Sign In)

Vanilla 1.1.4 is a product of Lussumo. More Information: Documentation, Community Support.

    •  
      CommentAuthorthehua
    • CommentTimeMar 1st 2006 edited
     
    This is my first, of hopefully many, Ruby on Rails tutorials. Please feel free to comment on my writings, the content, and perhaps errors in my understanding of this language.

    Thanks!

    Download the PDF version here: Create Todo List with Ruby on Rails - Beginner's Tutorial
    •  
      CommentAuthorthehua
    • CommentTimeMar 3rd 2006 edited
     
    Fg 1.0 in document v1.0 has an incorrect sitemap. Authors: is missing show, and Todos is missing add.
    •  
      CommentAuthorthehua
    • CommentTimeMar 4th 2006
     
    When inserting item into todo list and the description field is left blank, application crashes and does not prompt user that there is an invalid post item.

    Model controller should be taking care of this - I'm not sure why. Will look into this in the future.
    •  
      CommentAuthorthehua
    • CommentTimeMar 6th 2006
     
    There is confusion over plurality and singularity of Models, Controllers, Table names. I'm still under investigation of this but I will say this for now:

    Table names = plural
    Model names = singular

    When you scaffold models - that name has to match plural of table name

    Controllers = seems to be anything you desire.

    *Extra characters - it seems ruby automatically strips characters like '_' and etc.
    • CommentAuthorphil
    • CommentTimeMar 6th 2006
     
    Hey ..

    somehow the tutorial doesn't work for me. At the point where you try to modify the new.rhtml file I keep getting the same error. Since I'm quite new to Ruby and RoR I can't find anything wrong in the sourcecoude. However, here's the errormessage I get:
    You have a nil object when you didn't expect it!
    You might have expected an instance of Array.
    The error occured while evaluating nil.each

    It says that it must be somwehere around line 8 which is "<% @authors.each do |author| %>". Could it be that there is a = missing?

    Anyway, I would appreciate any kind of feedback. I want to go on witht this (so far) great tutorial. :)

    phil
    • CommentAuthorchenshack
    • CommentTimeMar 6th 2006
     
    hey phil,

    I think your problem might be with the variable @authors. It sounds to me like you might not have instantiated the variable with the code in the todos_controller file right above the step that you're at, where you say

    @authors = Author.find_all

    Try that out and let me know how that works, I'm pretty new at this stuff too but have other experience coding
    •  
      CommentAuthorthehua
    • CommentTimeMar 6th 2006
     
    Phil,
    if that doesn't work - does your database schema follow the suggestions from the tutorial? i.e. have you created an 'Authors' table and 'author' model in RoR?
    • CommentAuthorphil
    • CommentTimeMar 7th 2006
     
    Oh, chenshack was right. I forgat do put the variable in the todos_controller file. I just followed the tutorial step by step and forgot that I had to do the following step (which was editing the todos_controller file) too to successfully try it out.

    Thanks for your help, chenshack and thehua.
    •  
      CommentAuthorthehua
    • CommentTimeJul 17th 2006
     
    lol got mini-dugged today from http://digg.com/programming/TOP_30_Ruby_on_Rails_Tutorials
    cool i say :)
    • CommentAuthorbrad
    • CommentTimeJul 21st 2006
     
    I am having issues...
    NoMethodError in Todos#create

    undefined method `author.id=' for #<Todo:0xb7ab1d50>

    RAILS_ROOT: script/../config/..
    Application Trace | Framework Trace | Full Trace

    /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:1498:in `method_missing'
    /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:1337:in `attributes='
    /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:1336:in `attributes='
    /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/base.rb:1188:in `initialize_without_callbacks'
    /usr/lib/ruby/gems/1.8/gems/activerecord-1.13.2/lib/active_record/callbacks.rb:236:in `initialize'
    ./script/../config/../app/controllers/todos_controller.rb:21:in `create'

    Any ideas?
    •  
      CommentAuthorthehua
    • CommentTimeJul 21st 2006
     
    brad,
    check your todos_controller.rb, it says line 21 has an error. is it syntax? could you paste your code here if you can't figure it out?
    have you created the model author and the backend database with the appropriately scaffolded properties?
    • CommentAuthorarrowv
    • CommentTimeAug 26th 2006
     
    Hello,
    I keep getting an error that is mentioned below.

    Showing app/views/todos/list.rhtml where line #14 raised:

    "You have a nil object when you didn't expect it! The error occured while evaluating nil.name"

    It says that the error is on line 14

    14: <td><%= todo.author.name %></td>

    I have gone through the tutorial so many times and check all the code and I cannot figure out where I am going wrong. Please let me know if you know what is the cause of this error. Thanks
    •  
      CommentAuthorthehua
    • CommentTimeAug 27th 2006
     
    how is your database structured? do you have an Author model and a column Name? Todo.author.name retrieves the name based on relations of the models. that was my understanding when I wrote the help guide. If you've deviated from the naming structure, please change accordingly but bear in mind i'm not sure how scaffolding might impact these changes.
    • CommentAuthorrexaler
    • CommentTimeNov 9th 2006
     
    Nice tutorial :) thanks.. I have a working todo list now..
    •  
      CommentAuthorthehua
    • CommentTimeNov 10th 2006
     
    you're welcome :)
    • CommentAuthortrahan
    • CommentTimeMar 4th 2007
     
    Interesting tutorial, I just started messing around with RoR, and I found it to be very very cool. It makes like so nice and easy.

    http://media.rubyonrails.org/video/rails_take2_with_sound.mov

    I found that watching (and coding) the 15 min weblog video off the main site to be probably the best way to get started. Even though you said this in the tutorial, I can't stress how helpful it was, maybe you should make this a video :) Also, you should link to some information on MVCs in general. It makes the whole craziness of Rails then make sense to people who don't normally mess with stuff like this.

    Also, I think you need to add more to this tutorial. Like add Priorities and Deadlines. Then, you could do cool stuff like have your todo list automagically show you the most important items, and even send you notifications :)
    •  
      CommentAuthorthehua
    • CommentTimeMar 18th 2007
     
    why don't you write me a new tutorial trahan :)
    i haven't programmed in like a year lol
  1.  
    Hey, I've been working on the tutorial and I've got at least one bug that you're going to need to change, and another that I can't figure out at all that you may be able to help with...

    First of all, when one edits "001_authors.rb" and "002_todos.rb", it is no longer necessary to add the 'id' field as Rails does that on its own. Took me 4 hours last night and a few hours this morning to finally find the solution to the SQL error that kept popping up when I'd use "rake migrate".

    When I add "<td><%= todo.author.name %></td>" to app/views/todos/list.rhtml I get this error when I test it:

    " NoMethodError in Todos#list

    Showing app/views/todos/list.rhtml where line #13 raised:

    You have a nil object when you didn't expect it!
    The error occurred while evaluating nil.name

    Extracted source (around line #13):

    10:
    11: <% for todo in @todos %>
    12: <tr>
    13: <td><%= todo.author.name %></td>
    14: <% for column in Todo.content_columns %>
    15: <td><%=h todo.send(column.name) %></td>
    16: <% end %>

    RAILS_ROOT: script/../config/.."


    I've checked repeatedly and can't see anything I've missed. Any help on this appreciated.

    Also, your "Sign Up" link seems to have a problem tagging on a URL on the end of it, making it impossible to sign up unless you realize that you need to remove the last part.
  2.  
    I just noticed that user arrowv, above, has what sounds like the same thing I'm having.

    My database looks like it's been created correctly. I've got 3 tables: schema_info, authors, todos. Each one has an id, and other appropriate fields.

    I have one author.rb and one todo.rb and they appear to be correct so far.
  3.  
    Ok, I have an answer for my situation and it may help others with this.

    For some odd reason the author_id field wasn't populated in the todos table. Once I added some author_id's, it works fine.

    Now to figure out why the author_id isn't being set when I add the todos..
  4.  
    Final update: don't know what I did differently besides leaving out the id field so that it would migrate properly but now all seems to work fine. Must have been a typo that I simply couldn't see.
    •  
      CommentAuthorthehua
    • CommentTimeSep 21st 2007
     
    Thanks for the posts. I have stopped RoR development so unfortunately cannot assist with any potential errors or changes due to RoR releases. Thanks