If statement help please

Hi

I have created a page were users can make a rating for a product and add
this to a database, but when they do this the correct way teh item name
is moved to the rating page and used in a text box.

I want to secure my program by stopping users from using this page if
the try to go to it directly without going through a product screen.

Below is what I was thing of:

if (:item_name == “”) then(

error
)else {
<% form_for(@rating) do |f| %>

Item name
<%= f.text_field :item_name %>

Comment
<%= f.text_area :comment %>

Seller rating
<%= f.text_field :seller_rating %>

Advert rating
<%= f.text_field :advert_rating %>

<%= f.submit "Create" %>

<% end %>

<%= link_to ‘Back’, ratings_path %>
)

i cannot get anything like this to work though.

Here is the controller if it helps:

def new
@rating = Rating.new
if params[:product_name]
@rating.item_name = params[:product_name]
end

respond_to do |format|
  format.html # new.html.erb
  format.xml  { render :xml => @rating }
end

end

On 29 Mar 2008, at 18:06, Alan Red wrote:

the try to go to it directly without going through a product screen.

Below is what I was thing of:

If statements in erb files are fine:

<% if some condition %>

<% else %>

<% end %>

if (:item_name == “”) then(

I’m not sure why you wrote that but i’m guessing you meant
@rating.item_name == ‘’ (or even @rating.item_name.blank? )

Fred

Hi All,

I got Registered for Google Domains.I got My own Domain on my name. Now
i
want to Host a demo Rails Application on to my Google Domain.

1 . Is it possible to Setup Rails applications onto Google Domains ?

  1. If so, Please let me know where to place my Code and How to Setup My
    Application ?

Waiting for Kind Reply !

Cheers,
Rajesh

Hi Rajeshwar!

Welcome to the web development world.

I’m sure it’s possible.

Tell us, can you put html up on the site? Do they do dynamic content
hosting?

If you can tell us this, we can help you further :slight_smile:

Julian.

Learn about Ruby on Rails! CHECK OUT THE FREE VIDS (LIMITED TIME)
http://sensei.zenunit.com/