I have an instance variable @grp:
(app\controllers\zwemmers_controller.rb)
class ZwemmersController < ApplicationController
...
def initialize
@grp='or1r2r3r4gggrp'
end
attr_accessor :grp
...
end
When i click an image, i reload the main index page and try to change
the value of the variable:
(app\views\layouts\zwemmers.html.erb)
I have an instance variable @grp:
(app\controllers\zwemmers_controller.rb)
class ZwemmersController < ApplicationController
...
def initialize
@grp='or1r2r3r4gggrp'
end
In general I'd be wary of overriding initialize without calling super
(i think you're ok here though)
attr_accessor :grp
...
end
When i click an image, i reload the main index page and try to change
the value of the variable:
(app\views\layouts\zwemmers.html.erb)
You haven't shown anywhere where you're trying to set it - if you want
it to be set based on a parameter, you're going to have to set @grp to
params[:something]
You haven't shown anywhere where you're trying to set it - if you want
it to be set based on a parameter, you're going to have to set @grp to
params[:something]
Hm, i forgot the on_click in my code:
<%= link_to image_tag("oranje.png", :mouseover =>
image_path("oranje2.png"), :onclick => (:grp => 'o')), zwemmers_path %>
So when i click the image i want to redirect to zwemmers_path and i want
to change the value of @grp to 'o'. I don't know how to implement params
tho.
If you don't know about passing data back to the controller via params
then you need to run through some basic guides and tutorials. See the
Rails Guides (google it) and railstutorial.org is good.
Make sure that any tutorial you use matches the rails version you are
using (2 or 3). I would advise using Rails 3 unless you are to
maintain legacy apps.