i cant able to insert filename into database...pl;s help my model.rb class Mobile < ActiveRecord::Base validates_presence_of:image validates_presence_of:brand def mobile=(picture_field) self.image = picture_field[''image''].respond_to?(:original_filename) ? base_part_of(picture_field.original_filename) : nil end def self.save(product) name=product[''image''].original_filename path = File.join("public/data", name) File.open(path, "wb") { |f| f.write(product[''image''].read) } end end ......................................................... controller.rb def create @mobile=Mobile.new(params[:mobile]) if @mobile.save post=Mobile.save(params[:mobile]) redirect_to :action=>''list'' else render :action=>''new'' end end ........................................... new.rhtml <%= error_messages_for ''mobile'' %> <% form_tag ({ :action => ''create'' }, { :multipart => ''true'' }) do%> <p><%=text_field ''mobile'',''brand''%></p> <p><%=file_field ''mobile'',''image''%></p> <p><%=submit_tag ''Submit''%></p> <%end%> -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk?hl=en -~----------~----~----~----~------~----~------~--~---