In an *.rhtml, why do I need to add <% for product in @products %> in
order that I may call an . Is there not another way to skip the “for
product” line? I really dont want to include it. I tried @products =
product but it does not work. Can anyone help shed light on this matter?
Guest wrote:
In an *.rhtml, why do I need to add <% for product in @products %> in
order that I may call an. Is there not another way to skip the “for
product” line? I really dont want to include it. I tried @products =
product but it does not work. Can anyone help shed light on this matter?
Or better, how can I extract the data from the SQL Database one at a
time without using a for loop?
Guest wrote:
In an *.rhtml, why do I need to add <% for product in @products %> in
order that I may call an. Is there not another way to skip the “for
product” line? I really dont want to include it. I tried @products =
product but it does not work. Can anyone help shed light on this matter?
Hi, what do you want to do?
<% for product in @products %> will basically cause you to iterate over
the list of products, one at a time…
@products is a list (array) and at any give iteration of the loop
‘product’ is one of the elements in the array…
Cheers,
Mohit.
if think you want to use @product = Product.find(:first) instead of
@products = Product.find(:all)
2006/8/7, Mohit S. [email protected]:
Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails
–
Michael S. [email protected]
www.stellar-legends.de - Weltraum-Browsergame im Alpha-Stadium
Michael S. wrote:
if think you want to use @product = Product.find(:first) instead of
@products = Product.find(:all)2006/8/7, Mohit S. [email protected]:
Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails–
Michael S. [email protected]www.stellar-legends.de - Weltraum-Browsergame im Alpha-Stadium
Well, this is a simple template of an list.rhtml
[CODE]
Listare Carti
<% for book in @books %>
<% for column in Book.content_columns %> <% end %> <% end %>| Titlu | Subtitlu | Autor(i) | Editura | ISBN | Numar Inventar | URL Imagine | Data |
|---|---|---|---|---|---|---|---|
| <%=h book.send(column.name) %> | <%= link_to 'Arata', :action => 'show', :id => book %> | <%= link_to 'Modifica', :action => 'edit', :id => book %> | <%= link_to 'Sterge', { :action => 'destroy', :id => book }, :confirm => 'Are you sure?', :post => true %> |
<%= link_to ‘Pagina Anterioara’, { :page => @book_pages.current.previous
} if @book_pages.current.previous %>
<%= link_to ‘Pagina Urmatoare’, { :page => @book_pages.current.next } if
@book_pages.current.next %>
<%= link_to ‘Adauga Carte’, :action => ‘new’ %>
[CODE]
I want to replace the “<% for column in Book.content_columns %> <%=h
book.send(column.name) %>” so that I would be able to controll the
content myself, and insert an image far into the left of the table. How
can I do that?
I don’t want to offend you, but i think you should read a bit more about
what the scaffolding does. I’d recommend the “Four Days On Rails” PDF
(don’t
have a link, find it on Google).
greetz
2006/8/7, Guest [email protected]:
[CODE]
Data :confirm => 'Are you sure?', :post => true %>
Rails mailing list
[email protected]
http://lists.rubyonrails.org/mailman/listinfo/rails
–
Michael S. [email protected]
www.stellar-legends.de - Weltraum-Browsergame im Alpha-Stadium
–
Michael S. [email protected]www.stellar-legends.de - Weltraum-Browsergame im Alpha-Stadium
No offence taken, thanks for the advice, found the book and started
reading.
Mohit S. wrote:
<% end %> ### this ends the iteration of book in @books…
Hope this helps,
Mohit
Thanks alot Mohit for your help, it worked.
Guest wrote:
[CODE]
Data :confirm => 'Are you sure?', :post => true %><%= link_to ‘Adauga Carte’, :action => ‘new’ %>
[CODE]
I want to replace the “<% for column in Book.content_columns %>
<%=h ” so that I would be able to controll the
book.send(column.name) %>
content myself, and insert an image far into the left of the table. How
can I do that?
Ah! That makes sense now 
<% for column in Book.content_columns %>
<% end %>
This is basically from the scaffold which does not know which columns
you actually have in the database and instead queries the database to
find the information about the columns…
You can replace it with code that is something like this:
| Titlu | Subtitlu | Autor(i) | Editura | ISBN | Numar Inventar | URL Imagine | Data |
|---|---|---|
| <%=h book.titlu %> | ### this outputs the actual field..<%=h book.Subtitlu %> | ### this outputs the actual field..<%=h book.Autor %> | ### this outputs the actual field.. ....