activerecord - Rails: database not being updated after save is called -


i trying create association between 2 objects , save changes database. have included in notice call on object, test if saves after passes true if stament. when check see if update has occurred in data base nothing has changed.

requests_controller.rb

class requestscontroller < applicationcontroller    before_filter :load_requestable      def accept      @request = request.find(params[:id])      @request.profile.send("#{@belongs_to}=",@requestable)       if @request.save         redirect_to [@requestable, :requests], notice: "request accepted #{@request.profile.send("#{@belongs_to}").name}"      else        render :new      end    end  private    def load_requestable     klass = [company, profile].detect { |c| params["#{c.name.underscore}_id"]}     @requestable = klass.find(params["#{klass.name.underscore}_id"])     @belongs_to = klass.to_s.downcase   end  end 

try saving profile directly (since you're modifying it, not request object)

if @request.profile.save   # redirect 

Comments

Popular posts from this blog

c# - SVN Error : "svnadmin: E205000: Too many arguments" -

c# - Copy ObservableCollection to another ObservableCollection -

All overlapping substrings matching a java regex -