I want to access the variables of view in my controller.. What i
do is that the value that i m storing in view i want to store that
a variable by defining it in the controller..
That doesn't really make sense since usually the rendering of the
view happens after the controller code has executed. Views magically
get instance variables defined in the controller, but that doesn't
happen in the reverse direction.
This is still rather vague, but anyway the answer is 'Stop doing too much in the view'. Theres no good reason to do stuff like that in the view.
No one can guess what it is you're doing without seing any code.
<% for aggregator_item in @aggregator_items %>
<% if @desc =
<br /><% @timestamp = aggregator_item.send("timestamp") %>
<br /><%=h @link = aggregator_item.send("link") %>
<br /><%=h @desc%>
<br /><%=h @title = aggregator_item.send("title")%>
<br /><%= Time.at(@timestamp) %>
<% "insert into email(mail,subject,source) VALUES
<% end %>
<% end %>
You could very easily have all of this in a model. The model would
insert them into the database, (why are you using sql rather than the
corresponding ActiveRecord class?) and return an array of these
activerecord objects, which you would iterate over in the view.
can you tell me how do i write the same thing in model/?
It's pretty much what you've got in your view - iterate over your
aggregator objects, pull out the values you want and pass them to
Don't write sql. Do use activerecord. if you're inserting to the emails table then it's just Email.create, passing the desired attributes as a hash.