# If statement help please

**URL:** <https://www.ruby-forum.com/t/if-statement-help-please/133283>\
**Category:** Rails\
**Created:** [March 29, 2008, 7:06pm UTC](https://www.ruby-forum.com/t/if-statement-help-please/133283 "2008-03-29T19:06:11Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![megax](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/94ad74/32.png) [@megax](https://www.ruby-forum.com/u/megax)\
**Post date:** [March 29, 2008, 7:06pm UTC](https://www.ruby-forum.com/t/if-statement-help-please/133283/1 "2008-03-29T19:06:11Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![megax](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/94ad74/32.png) [@megax](https://www.ruby-forum.com/u/megax)\
**Post date:** [March 29, 2008, 7:28pm UTC](https://www.ruby-forum.com/t/if-statement-help-please/133283/2 "2008-03-29T19:28:17Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![megax](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/94ad74/32.png) [@megax](https://www.ruby-forum.com/u/megax)\
**Post date:** [March 29, 2008, 7:28pm UTC](https://www.ruby-forum.com/t/if-statement-help-please/133283/3 "2008-03-29T19:28:17Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![megax](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/m/94ad74/32.png) [@megax](https://www.ruby-forum.com/u/megax)\
**Post date:** [March 31, 2008, 8:17am UTC](https://www.ruby-forum.com/t/if-statement-help-please/133283/4 "2008-03-31T08:17:39Z")

</div>

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 🙂

Julian.

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