I was trying to create a radio button in scaffold form but got error
here is the form codes-
<%= form_for(@value) do |f| %>
<% if @value.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@value.errors.count, "error") %> prohibited
this value from being saved:</h2>

<ul>
<% @value.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>

<div class="field">
<%= f.label :fname %><br />
<%= f.text_field :fname %>
</div>
<div class="field">
<%= f.label :lname %><br />
<%= form.radio_button :lname, 'yes I have' %> <!-- <label
id="helper.radio"/> -->
<%= form.label :red %>
<%= form.radio_button :lname, 'No I don't' %>
<%= form.label :yellow %>
</div>

<div class="actions">
<%= f.submit %>
</div>
<% end %>
but when I clicked on new button. It's giving me this error-
SyntaxError in Values#new

Showing /home/vmuser/workspace/trial-9/app/views/values/_form.html.erb
where line #22 raised:

/home/vmuser/workspace/trial-9/app/views/values/_form.html.erb:22:
syntax error, unexpected tIDENTIFIER, expecting ')'
...adio_button :lname, 'No I don't' );@output_buffer.safe_conca...
... ^
/home/vmuser/workspace/trial-9/app/views/values/_form.html.erb:28:
unknown regexp options - dv
unmatched close parenthesis: /div>

<div class="actions">
');@output_buffer.append=
( f.submit );@output_buffer.safe_concat('
');@output_buffer.safe_concat(' </i
/home/vmuser/workspace/trial-9/app/views/values/_form.html.erb:29:
unterminated string meets end of file
/home/vmuser/workspace/trial-9/app/views/values/_form.html.erb:29:
syntax error, unexpected $end, expecting ')'

Extracted source (around line #22):

19: <%= f.label :lname %><br />
20: <%= form.radio_button :lname, 'yes I have' %> <!-- <label
id="helper.radio"/> -->
21: <%= form.label :red %>
22: <%= form.radio_button :lname, 'No I don't' %>
23: <%= form.label :yellow %>
24: </div>
25:

--
You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
To post to this group, send email to rubyonrails-talk@googlegroups.com.
To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Search Discussions

  • Colin Law at Apr 20, 2012 at 7:45 am

    On 19 April 2012 22:07, Padmoja Roy wrote:
    ...
    Showing /home/vmuser/workspace/trial-9/app/views/values/_form.html.erb
    where line #22 raised:

    /home/vmuser/workspace/trial-9/app/views/values/_form.html.erb:22:
    syntax error, unexpected tIDENTIFIER, expecting ')'
    ...adio_button :lname, 'No I don't' );@output_buffer.safe_conca...
    Surely you can see the error here, you have single quote character in
    the middle of a string using single quote to identify it. Ruby will
    see the string as 'No I don' and is then confused by the t character.
    Use "No I don't" instead.

    Colin

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Padmoja Roy at Apr 20, 2012 at 12:09 pm
    Thanks....I fixed it . But now it's giving me this error-

    Trace of template inclusion: app/views/values/new.html.erb

    undefined method `radio_button' for nil:NilClass

    Extracted source (around line #20):

    17: </div>
    18: <div class="field">
    19: <%= f.label :lname %><br />
    20: <%= form.radio_button :lname, "yes I have"%> <!-- <label
    id="helper.radio"/> -->
    21: <%= form.label :red %>
    22: <%= form.radio_button :lname, "No I don't"%>
    23: <%= form.label :yellow %>

    Trace of template inclusion: app/views/values/new.html.erb

    Rails.root: /home/vmuser/workspace/trial-9
    Application Trace | Framework Trace | Full Trace

    app/views/values/_form.html.erb:20:in `block in
    _app_views_values__form_html_erb__544020744__641603598'
    app/views/values/_form.html.erb:1:in
    `_app_views_values__form_html_erb__544020744__641603598'
    app/views/values/new.html.erb:3:in
    `_app_views_values_new_html_erb__132110805__641585578'
    app/controllers/values_controller.rb:31:in `new'


    On Apr 20, 3:45 am, Colin Law wrote:
    On 19 April 2012 22:07, Padmoja Roy wrote:

    ...
    Showing /home/vmuser/workspace/trial-9/app/views/values/_form.html.erb
    where line #22 raised:
    /home/vmuser/workspace/trial-9/app/views/values/_form.html.erb:22:
    syntax error, unexpected tIDENTIFIER, expecting ')'
    ...adio_button :lname, 'No I don't' );@output_buffer.safe_conca...
    Surely you can see the error here, you have single quote character in
    the middle of a string using single quote to identify it.  Ruby will
    see the string as 'No I don' and is then confused by the t character.
    Use "No I don't" instead.

    Colin
    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Colin Law at Apr 20, 2012 at 1:57 pm

    On 20 April 2012 13:08, Padmoja Roy wrote:
    Thanks....I fixed it . But now it's giving me this error-

    Trace of template inclusion: app/views/values/new.html.erb

    undefined method `radio_button' for nil:NilClass

    Extracted source (around line #20):

    17:   </div>
    18:    <div class="field">
    19:     <%= f.label :lname %><br />
    20:     <%= form.radio_button :lname, "yes I have"%> <!-- <label
    id="helper.radio"/> -->
    Once again the error is not difficult to see if you look carefully.
    The error says undefined method radio_button for something that is nil
    and tells you the line. Look at the line, what variable are you
    calling radio_button on? What is the value of that variable?

    Colin

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Padmoja Roy at Apr 20, 2012 at 2:10 pm
    Thanks.....I got it....actually last few days I was trying to fix the
    issue and tried to type lots of stuffs...my mistake was mainly cotton
    marks.....thanks for your assistance ...I like this forum....
    On Apr 20, 9:57 am, Colin Law wrote:
    On 20 April 2012 13:08, Padmoja Roy wrote:

    Thanks....I fixed it . But now it's giving me this error-
    Trace of template inclusion: app/views/values/new.html.erb
    undefined method `radio_button' for nil:NilClass
    Extracted source (around line #20):
    17:   </div>
    18:    <div class="field">
    19:     <%= f.label :lname %><br />
    20:     <%= form.radio_button :lname, "yes I have"%> <!-- <label
    id="helper.radio"/> -->
    Once again the error is not difficult to see if you look carefully.
    The error says undefined method radio_button for something that is nil
    and tells you the line.  Look at the line, what variable are you
    calling radio_button on?  What is the value of that variable?

    Colin
    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.
  • Colin Law at Apr 20, 2012 at 4:10 pm

    On 20 April 2012 15:10, Padmoja Roy wrote:
    Thanks.....I got it....actually last few days I was trying to fix the
    issue and tried to type lots of stuffs...my mistake was mainly cotton
    marks.....thanks for your assistance ...I like this forum....
    It is always worth looking at the error carefully and trying to work
    out what it means. That is not always obvious but will get easier
    with practice.

    Colin

    --
    You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
    To post to this group, send email to rubyonrails-talk@googlegroups.com.
    To unsubscribe from this group, send email to rubyonrails-talk+unsubscribe@googlegroups.com.
    For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en.

Related Discussions

Discussion Navigation
viewthread | post
Discussion Overview
grouprubyonrails-talk @
categoriesrubyonrails
postedApr 20, '12 at 1:12a
activeApr 20, '12 at 4:10p
posts6
users2
websiterubyonrails.org
irc#RubyOnRails

2 users in discussion

Padmoja Roy: 3 posts Colin Law: 3 posts

People

Translate

site design / logo © 2022 Grokbase