Get cookie valuu into the model

How can i get the value of a cookie into the model.

(cookies[:mycookie])

In the model i get a undefined method.
I understand this is not supported by Activereccord::base

But how can i get this values evan as remote_ip and other values.
For my rails app i need some important values but in the model i can’t
get one of them.

On Fri, Oct 9, 2009 at 12:36, GG9 Rails
[email protected] wrote:

get one of them.
Trying to access cookies (and other HTTP/web specific things) from the
model seems like a bad idea. This would make it very difficult to use
the same models from any command-line scripts, or anything that wasn’t
HTTP/web based. Why not have the controller pass these values down to
the model, where the model can do what you wish with them?

The reason i want to do that is because ia’m writing a program using
Paperclip in combination that can upload your picture in different
sizes.
For now i have this

def self.last_avatar
Avatar.find(:last)
end

def self.new_avatar_size
last_avatar.avatar_size
rescue
“48x48”
end

has_attached_file :avatar, :styles => { :small => new_avatar_size, :large => >“500x500>” },

This works well only there is one problem

User1 choose the size of 40x40
user2 choose the size of 80x80

User2 is done before user1
In that case user1 gots the size of user2 80x80

Now i try to avoid this on severeal ways.
But each time i have the problem that i can’t use this way into a model.
Cookies, remote_ip nothing is possible into the model.

Maybe there is a way too use has_attached_file into the controller or
something.

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs