User Setting

<%= debug(@settings) %> <% form_for :settings, @settings, :url => { :action => "update" } do |f| %> First name: <%= f.text_field :firstname %>
Last name : <%= f.text_field :lastname %>
Contact number: <%= f.text_field:contact_number%>
Email : <%= f.text_field:email%>
Setup number: <%= f.text_field:setup_number%>
<%= submit_tag 'Save' %> <% end %> class UserSettingController < ApplicationController def create end def view @id = params[:user_id] @settings = Settings.find_by_user_id(@session['user_id']) if !@settings.nil? @settings = Settings.new @settings.user = @session['user'] @settings.save end @user = session['user'] @user['Settings'] = @settings end def new @settings = Settings.new end def edit # @settings = Settings.find_by_user_id(@session['user']) end def update # @settings.save @settings = Settings.find(params[:id]) if @settings.update_attributes(params[:settings]) flash[:notice] = 'Your settings have been saved.' #redirect_to :action => 'show', :id => @campaign redirect_to :action => 'view', :id => @settings else render :action => 'view', :id => @settings end end end