Forum: Ruby on Rails help with code

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
Jose vicente R. (Guest)
on 2009-03-26 19:05
Hi everybody, first at ll sorry if my english is not the best. I'm
trying to implement this javascript in my aplication:

http://www.ribosomatic.com/articulos/barra-de-cali...

It´s a simple start rating implemented with javascript. There´s no
problem because I put it in public/javascripts and i can call them in my
application.html.rb but there´s one problem. I have this in my view:

.
.
.


  <form name="test" action="" method="post">
        <input type="hidden" id="input-rating" name="input-rating"
value="<?= $_POST["input-rating"] ?>" />
        <div id="rater" class="rater">
            <div id="stars"></div>
            <div class="clear"></div>
        </div>

        <input name="submit" type="submit" value="Votar" />
    </form>
<?php
  if(isset($_POST)): echo("Value is: ".$_POST["input-rating"]); endif
?>
<script language="javascript">
  var pValue = '<?= $_POST["input-rating"] ?>';
  var r = new rating('stars', 5,  pValue || 0 , true, 'input-rating');
</script>
.
.
.
I don´t know PHP, and I understant this lines:
<?php
  if(isset($_POST)): echo("Value is: ".$_POST["input-rating"]); endif
?>

Anybody that works with PHP too can says me the equivalence for rails??
Starr H. (Guest)
on 2009-03-26 19:34
(Received via mailing list)
On Thu, 26 Mar 2009 18:05:54 +0100
Jose vicente Ribera pellicer <removed_email_address@domain.invalid> wrote:

> I don´t know PHP, and I understant this lines:
> <?php
>   if(isset($_POST)): echo("Value is: ".$_POST["input-rating"]); endif
> ?>
>
> Anybody that works with PHP too can says me the equivalence for rails??

Post parameters are available in the view via the params method. Are you
seriously trying to put PHP code in your views? Or do you want to port
the php to ruby?

SH

--
Starr H.
Check out my Helpdesk RailsKit: http://railskits.com/helpdesk/
Jose vicente R. (Guest)
on 2009-03-26 19:53
>  Are you
> seriously trying to put PHP code in your views? Or do you want to port
> the php to ruby?
>
> SH


I want to port the php, but i am a begginer developper and i only
program with RoR. I don't know how to port it to my rails application :(
Jose vicente R. (Guest)
on 2009-03-26 20:07
Jose vicente Ribera pellicer wrote:
>>  Are you
>> seriously trying to put PHP code in your views? Or do you want to port
>> the php to ruby?
>>
>> SH
>
>
> I want to port the php, but i am a begginer developper and i only
> program with RoR. I don't know how to port it to my rails application :(

I try with this:

<%-  if(isset($_POST)): echo("Value is: ".$_POST["input-rating"]); endif
%>


but firefox shows me this error:
 SyntaxError in Videos#show

Showing videos/show.html.erb where line #17 raised:

compile error
/Users/jose/mimandote.com/app/views/videos/show.html.erb:17: syntax
error, unexpected tGVAR
_erbout.concat((  if(isset($_POST)): echo("Value is:
".$_POST["input-rating"]); endif ).to_s); _erbout.concat "\n"
                                                             ^
/Users/jose/mimandote.com/app/views/videos/show.html.erb:17: syntax
error, unexpected ')', expecting kEND
_erbout.concat((  if(isset($_POST)): echo("Value is:
".$_POST["input-rating"]); endif ).to_s); _erbout.concat "\n"
                                                                              ^
/Users/jose/mimandote.com/app/views/videos/show.html.erb:35: syntax
error, unexpected $end, expecting ')'

Extracted source (around line #17):

14:         <input name="submit" type="submit" value="Votar" />
15:     </form>
16:
17: <%=  if(isset($_POST)): echo("Value is: ".$_POST["input-rating"]);
endif %>
18:
19: <script language="javascript">
20:   var pValue = '<?= $_POST["input-rating"] ?>';



:(
This topic is locked and can not be replied to.