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.
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.
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.
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. :)
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
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?
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.
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?
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
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.
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 :)
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.
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.