I am using attachment fu for image uploading. I try to customize the
path for pictures be saved.
If I call session[:kwikerhash] in the image.rb where there method for
path definition is I get an undefined method or variable error. If I
fill a global variable @kwikerhash in the controller with the session
value and try to use it in the image.rb it says that @kwikerhash is nil.
Is there a possibility to get access to session values in model files?
Is there a possibility to get access to session values in model files?
You can't do that and if any means doing that means violating MVC .
What you can do is to pass the session variable from controller to model
For example in the image.rb you have a
Is there a possibility to get access to session values in model files?
You can't do that and if any means doing that means violating MVC .
What you can do is to pass the session variable from controller to model
For example in the image.rb you have a
def do_this(session_id)
----
end
So from controller you can pass it like
@image_model_obj.do_this(session[:kwikerhash])
Sijo
Hi Sijo
you're right. But if I set a value to @kwikerhash in the controller I
have also access to it in the view.
This is fucked. Because its a method which I override from the
attachment_fu plugin.
So I need to create the same method with parameters.
sorry but I have no Idea how to solve it. I try to explain the problem.
I am using attachment_fu for picture upload and output. I wanna change
the attachment-fu to save the pics in a specific folder. Therefor my
image.rb looks
File.extname(file_data.original_filename) if respond_to?(:filename)
if file_data.is_a?(StringIO)
file_data.rewind
self.temp_data = file_data.read
else
self.temp_path = file_data.path
end
end
# START: FOLDER STRUCTURE MODIFYING CODE
# Changes the folder structure
def full_filename(thumbnail = nil)
file_system_path = (thumbnail ? thumbnail_class :
self).attachment_options[:path_prefix]
File.join(RAILS_ROOT, file_system_path,
created_at.strftime("%Y/%m/%d"), thumbnail_name_for(thumbnail))
end
end
I want to replace the created_at.strftime("%Y/%m/%d") in the
full_filename method with the value which is set in
session[:kwikerhash]. But I don't know how. The view file calls a method
image.public_filename(:thumb) for example.
What can I do to let the full_filename method take the value from the
session?