Forum: Ruby on Rails assiging an attribute in rhtml

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.
Jason (Guest)
on 2005-12-11 01:06
This might be a stupid question, but I am quite the noob and I can't
find it in agile.

I have this in my html:

<span class='class'><%= dynamic content %></span>

and I want to put

<span class='class' name=@ruby_variable ><%= dynamic content %></span>

so I can put it as a target from another page.

cheers,

Jason
jeremyevans0 (Guest)
on 2005-12-11 01:37
(Received via mailing list)
On 12/10/05, Jason <removed_email_address@domain.invalid> wrote:
> <span class='class' name=@ruby_variable ><%= dynamic content %></span>

<span class='class' name='<%= @ruby_variable %>'><%= dynamic content
%></span>
Jason <> (Guest)
on 2005-12-11 01:57
jeremyevans0 wrote:
> On 12/10/05, Jason <removed_email_address@domain.invalid> wrote:
>> <span class='class' name=@ruby_variable ><%= dynamic content %></span>
>
> <span class='class' name='<%= @ruby_variable %>'><%= dynamic content
> %></span>

Thanks.  I'm saying to myself duuuh!  Brainfart.
ezra (Guest)
on 2005-12-11 02:30
(Received via mailing list)
On Dec 10, 2005, at 3:06 PM, Jason wrote:

>
> Rails mailing list
> removed_email_address@domain.invalid
> http://lists.rubyonrails.org/mailman/listinfo/rails
>


Try this:


> <span class='class' name=<%= @ruby_variable %> ><%= dynamic content
> %></span>

-Ezra Z.
WebMaster
Yakima Herald-Republic Newspaper
removed_email_address@domain.invalid
509-577-7732
Bruce B. (Guest)
on 2005-12-11 02:38
(Received via mailing list)
I'm a noob also.  I believe the answer is to rap the @ruby_variable
in the erb delimiters so

name=<%=@ruby_variable %>

bruce
Jason <> <> (Guest)
on 2005-12-11 04:07
brucebalmer wrote:
> I'm a noob also.  I believe the answer is to rap the @ruby_variable
> in the erb delimiters so
>
> name=<%=@ruby_variable %>
>
> bruce

hey bruce, the solution jeremy posted works.  I had thought that putting
putting ruby code <%= @variable %> in quotes '<%= @variable %>' would
force a string and not ruby.

But that works.
Rich (Guest)
on 2005-12-11 04:49
(Received via mailing list)
You should quote the name. Avoid problems and make "good" html.

     <span class='class' name='<%= ruby_var %>'><%= dynamic content
%></span>

My current project uses many of these for using same structure with
different
classes:

     <span class='<%= class_var %>' id='<%= id_var %>'><%= dynamic
content
%></span>

Also: 'id' should generally be used rather than 'name'.  I believe it's
safe
to say that 'id' will respond
everywhere 'name' would, plus 'id' can be used as an object: <span
id='xyz'><script>xyz.style...
(But sometimes I use the same 'name' for multiple objects to do group
operations: document.all('myButtons').style...)

Rich C.


----- Original Message -----
From: "Bruce B." <removed_email_address@domain.invalid>
To: <removed_email_address@domain.invalid>
Sent: Saturday, December 10, 2005 4:37 PM
Subject: Re: [Rails] assiging an attribute in rhtml
Rich C. (Guest)
on 2005-12-12 21:49
(Received via mailing list)
By way of correction of myself...

> Also: 'id' should generally be used rather than 'name'.  I believe it's safe
> to say that 'id' will respond everywhere 'name' would...

You still need to use 'name' in form variables, 'id' is not adequate.

<input type=text NAME=whatever...

Rich C.


----- Original Message -----
From: "Rich C." <removed_email_address@domain.invalid>
To: <removed_email_address@domain.invalid>
Sent: Saturday, December 10, 2005 6:46 PM
Subject: Re: [Rails] assiging an attribute in rhtml
This topic is locked and can not be replied to.