when the cubmit button is clicked it should go the a new controller
called fileuploader which has method name “create”
if the create action isn’t on the same controller as the create
action, you need to specify it, ie
:url => { :action => “create”, :controller =>
‘some_other_controller’ }
when the cubmit button is clicked it should go the a new controller
called fileuploader which has method name “create”
if the create action isn’t on the same controller as the create
action, you need to specify it, ie
:url => { :action => “create”, :controller =>
‘some_other_controller’ }
Fred
thanks a lot for it pal it works.
now another prob PAL,
in my create method their is a condition to forward to two different
pages according to the condition value.
if ( condition )
render_action ‘success’ #file is in the given format
else
render_action ‘new’ #file is not in the given format
end
when i use this it give a error as
Template is missing
my success.rhtml and new.rhtml pages are in a different folder called
“test”(that one is in the app folder) so how to over come this
problem…
To be quite honest, I’m not sure why you’ve put these in different
controllers. That said you can do stuff like render :template =>
‘some_controller/some_action’
my success.rhtml and new.rhtml pages are in a different folder called
“test”(that one is in the app folder) so how to over come this
problem…
To be quite honest, I’m not sure why you’ve put these in different
controllers. That said you can do stuff like render :template =>
‘some_controller/some_action’
Fred
ok pal thanks a lot for the advice.
i wrote in a different controls so the function i wrote can be used by
many places with out repeating the same code again and again in
different controls.
so here the problem i am facing now is, according to the given condition
i have to send the error messages to back to the calling page. so do do
such a thing i could not found a working redirection method.
but at thir i had to hard codes the going back codes. like
redirect_back_or_default :controller => “myfuel”, :action => “index”
so when some one used my above controle code they will face problem like
finding a given path.
so want i want to do is when some one use my controller and do the
validation it should be able to send the feed back to calling page with
out we have to specifically saying to it.
eg
redirect_back_or_default :controller => “…”, :action => “…”
the controller and the action will be able to get from the data that
comes when it calling my controller
so hope u guys got the point what i am going to say and hope i may get a
good reply…
because mycontroller should be the name of your controller, i used it
only as example (we use path generator functions of the edge version,
since they’re more convenient than this :url => {…} stuff
plus we use RESTful routing
so the details, how to call your controller and hand over attributes may
be different.
the trick without that is to hand over request.request_uri as an
attribute in your link. however you decide to manage that
because mycontroller should be the name of your controller, i used it
only as example (we use path generator functions of the edge version,
since they’re more convenient than this :url => {…} stuff
plus we use RESTful routing
so the details, how to call your controller and hand over attributes may
be different.
the trick without that is to hand over request.request_uri as an
attribute in your link. however you decide to manage that
because mycontroller should be the name of your controller, i used it
only as example (we use path generator functions of the edge version,
since they’re more convenient than this :url => {…} stuff
plus we use RESTful routing
so the details, how to call your controller and hand over attributes may
be different.
the trick without that is to hand over request.request_uri as an
attribute in your link. however you decide to manage that
<%= g.hidden_field :condition_file_type, :value => "APPLICATION" -%>
<% end %>
my controller is like this
def create
@temp_file = @params["form_file"]["upload_file"]
@file_name = @temp_file.original_filename
upload_file_type = @temp_file.content_type
condition_file_type = @params["form_file"]["condition_file_type"]
upload_file_type = upload_file_type.chop.upcase
if (@temp_file !="")
if ( ckeck_file(upload_file_type, condition_file_type) )
f = File.new("./uploads/nad/#{@file_name}", "wb");
f.write (@temp_file.read);
f.close;
# what i want here is from here send success msg to calling form
else
#file is not in the given format
# what i want here is from here send error msg to calling form
end
else
#their is no file to be upload
# what i want here is from here send error msg to calling
file_types = ["JPG","JPEG","GIF","PNG","MSWORD","PDF"]
file_types.each do |check|
check_string=condition_file_type+"/"+check
puts check_string
if (upload_file_type.eql?(check_string))
puts check_string
return true;
end
end
return false;
end
my form code is like this but i tried to add ur code but could not find
a way to do it… if can pls help
in those conditions i want to i want to send the error or success to the
back to the page it calls i tried some coding bt i wont display the msg
send by the control.
does not know if my way is correct
and idea how can i over come that problem
it’s most likely the flash object you wanna use there
in the controller:
flash[:return_msg] = “my message”
in the view:
<%= flash[:return_msg] if flash[:return_msg] %>
Thanks a it PAL it works.
bythe way to send a error msg to the other page the use of flash object
is a correct way or not. bz i am new to the RUBY i do not know weather i
use a correct concept or not. is their a define way to send error msg in
RUBY.??
bythe way to send a error msg to the other page the use of flash object
is a correct way or not. bz i am new to the RUBY i do not know weather i
use a correct concept or not. is their a define way to send error msg in
RUBY.??
“Flash†is an internal storage container (actually a kind of hash) that
Rails uses for temporary data between actions. Items stored in the flash
exist for the duration of exactly one action, and then they’re gone.
i used it in this case, because you wanted to send a message if error or
not
normally you would add errors to your ActiveRecord object
if your model is named User (and an instance @user) , then you can do
things like this:
add an error to an attribute: @user.errors.add(:name, “name can’t be blank”)
add an error to the ‘whole’ record: @user.errors.add_to_base(“another error”)
there are ActionView::Helpers::ActiveRecordHelper to show errors in the
view:
error_message_on @user, :name
and:
error_messages_for @user