Forum: Rails Germany Controller_name in onchange-event

Posted by Dieter Scherthan (mogli)
on 2009-04-07 08:10
Hallo zusammen,

wie bekomme ich den Controllername in ein onchange-event einer
collection_select eingebunden. Folgendes habe ich probiert, funktioniert
aber nicht:

<%= collection_select(:account, :account_id, Account.find(:all,
:conditions => "typ_id = 10000"), :id, :matchcode,{},
{:onchange => "document.location.href='/" + <%=
controller.controller_name -%> + "/' +
this.options[this.selectedIndex].value", :selected =>
session[:account_id]})%>
Posted by Alex Peuchert (Guest)
on 2009-04-07 09:55
(Received via mailing list)
lass mal das <%= ... -%> um controller.controller_name weg; du bist
schon im Ruby Code

-Alex


2009/4/7 Dieter Scherthan <lists@ruby-forum.com>:
Posted by Dieter Scherthan (mogli)
on 2009-04-07 10:13
Alex Peuchert wrote:
> lass mal das <%= ... -%> um controller.controller_name weg; du bist
> schon im Ruby Code
> 
> -Alex
> 
> 
> 2009/4/7 Dieter Scherthan <lists@ruby-forum.com>:

OK, hätte mir auch auffallen können.
Allerdings funktioniert es dann immer noch nicht, habe folgendes 
getestet:

"document.location.href='/' controller.controller_name '/' + 
this.options[this.selectedIndex].value"

"document.location.href='/' + controller.controller_name + '/' + 
this.options[this.selectedIndex].value"

"document.location.href='/controller.controller_name/' + 
this.options[this.selectedIndex].value"

Wie sieht denn die richtige Variante aus, st du mir da nochmal helfen
Posted by Dieter Scherthan (mogli)
on 2009-04-07 11:00
Juhu, Lösung selber gefunden:

"document.location.href='/" + controller.controller_name.to_s + "/' + 
this.options[this.selectedIndex].value"

Danke
Posted by Niko Dittmann (Guest)
on 2009-04-07 11:14
(Received via mailing list)
hm… bin mir nicht sicher… aber mach nicht #controller_path genau das?

Niko.

Am 07.04.2009 um 11:00 schrieb Dieter Scherthan:
Please log in before posting. Registration is free and takes only a minute.
Existing account (Switch to SSL-encrypted connection)
NEW: Do you have a Google/GoogleMail or Yahoo account? No registration required!
Log in with Google account | Log in with Yahoo account
No account? Register here.