Just trying to understand a bit more about the problems that I
had with the tutorial and learned something more, so I''m just updating
it a bit :-)
As for problem [3], I had recommended that you change the code to:
-> <%= Note.find (@item.note_id).more_notes
%>
Just want to update that a bit. It should ideally be:
-> <%=h Note.find (@item.note_id).more_notes
%>
The "h" after the "<%=" is needed cos it
''escapes'' the HTML
(see the description on Page 18 of the tutorial).
That''s all.
Cheers
mohit.
Mohit Sindhwani wrote:
Hi, I spent more than 4 days getting done with the "Four Days
with Rails" tutorial, mostly because I ran into a few issues that
seemed to stop me in my tracks. But, after looking around, I was able
to find the problems and solve them (in whatever way I thought best) :-)
I''m posting the whole list of problems that I ran into with "Four
Days
with Rails" to the list so that I can get comments about the ways that
the problems were solved. Also, this way, it will help everyone since
Google will probably pick up and index the list and the next time
someone searches for these problems while doing that tutorial, they
will find all the issues in one place :-)
The problems are as follows:
[1] You may find that most of the delete links do not work in the
modified code that you use. After searching the web, I found (with
respect to another application) that actions to ''destroy''
records (the
first time you meet this problem will be when you try to delete
Categories from your newly designed page) must be ''posted'' to
the
server.
In the file: app\views\categories\list.rhtml find the following lines:
<%= link_to ''Delete'', {:action =>
''destroy'', :id
=> category},
:confirm => "Are you sure you want to delete this
category?"
%>
and change it to:
<%= link_to ''Delete'', {:action =>
''destroy'', :id
=> category},
:confirm => "Are you sure you want to delete this
category?",
:post => true %>
You will need to do the same for deleting Items as well.
[2] I experienced a number of issues related to the fact that the code
in the tutorial uses TinyInt for some of the fields - priority, done,
etc. For some reason, Rails seems to interpret the TinyInt fields as
being boolean and requires you to enter "True" or "False"
for it (which
is mandated by giving you a select field with "True" and
"False" as the
options). You will notice this problem when you scaffold the
application. If you follow through the tutorial, you will change the
entry field to be a select that picks from "1" to "5" but
the
validation will continue to fail for this field.
Rails will continue to give you an error saying that the priority
should be between 1 (High) and 5 (Low). After you change this field to
being a SmallInt (use phpMyAdmin or something similar for this), it
will work as if there were no problems at all. The scaffolded code
will work just fine at this point.
The same problem affects one of the checks in the listing of the
items. The tick mark (indicating done) will not appear because the
code expects to be dealing with integers while Rails seems to be
thinking that it is working with boolean values.
In the file: app\views\items\_list_stripes.html you need to change the
test to compare against true as shown below:
<%= list_stripes["done"] =true ?
show_image("done_ico.gif") : " " %>
The original code that tests the value against 1 is as below (Page 29):
<%= list_stripes["done"] =1 ?
show_image("done_ico.gif") : " " %>
The other way would be to change the type of the "Done" and
"Private"
fields to be SmallInt so that the rest of the code works works fine.
[3] Finally, in the file app\views\items\editrhtml you will need to
change the line below:
-> <%=h @item.note.more_notes %>
Rails will complain that "note" is not an operation defined on the
item
and will not be able to find the text for the note. I changed the
code to look up the database and fine the note using the ID of the note
attached to the item in question. This results in the line shown below:
-> <%= Note.find (@item.note_id).more_notes
%>
If you find (or know) that there are other or better ways to solve the
problems above without deviating from the tutorial, do let me know.
Cheers,
Mohit.
_______________________________________________
Rails mailing list
Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails
_______________________________________________
Rails mailing list
Rails-1W37MKcQCpIf0INCOvqR/iCwEArCW2h5@public.gmane.org
http://lists.rubyonrails.org/mailman/listinfo/rails