I am trying to do edit profile in my app.When i inserted the new setting and updating it it is giving me the below error.
Error:
wrong number of arguments (1 for 0)
Rails.root: C:/Site/library_management1
Application Trace | Framework Trace | Full Trace
app/controllers/homes_controller.rb:148:in `updatedata'
My codes are as follows
views/homes/userprofile.html.erb
<% if current_user %>
<div class="totaldiv">
<div class="navdiv"><span>STUDENT INFORMATION</span><span>Logged in as <%= current_user.email %></span></div>
<div class="wrapper">
<div id="leftsidebtn">
<ul>
<li><a href="/homes/issuebooks">Book issue</a></li>
<li><a href="/homes/availablebooks">Books Available</a></li>
<li><a href="/homes/magazines?user_id=<%= current_user.id %>">Magazines Purchase</a></li>
<li><a href="/homes/newspaper">Newspaper Purchase</a></li>
<li><a href="/homes/userprofile">Profile settings</a></li>
<li><a href="/homes/blog">My Blog</a></li>
<li><a href="/sessions/removeuser">Log Out</a></li>
</ul>
</div>
</div>
<div class="restdiv" id="ex3" >
<center>
<div class="edit-profile"><button type="button" class="btn btn-success" id="btnShowModal" >Edit Your Profile</button></div>
<div id="output"></div>
<div id="overlay" class="web_dialog_overlay"></div>
<div id="dialog" class="web_dialog">
<div class="edit-firstdiv">
<div class="web_dialog_title align_right">
<a href="#" id="btnClose">Close</a>
</div>
<%= form_for :users,:url => {:action => 'updatedata',:id => params[:id] } do |f| %>
<% if @users.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@users.errors.count, "error") %> prohibited this post from being saved:</h2>
<ul>
<% @users.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div class="edit-firstname">
<label for="first_name">First Name</label>
<%= f.text_field :first_name,:id => 'first_name',:value => @users.first_name %>
</div>
<div class="edit-lastname">
<label for="last_name">Last Name</label>
<%= f.text_field :last_name,:id => 'first_name',:value => @users.last_name %>
</div>
<div class="edit-emailid">
<label for="emailid">Emailid</label>
<%= f.email_field :email,:id => 'first_name',:value => @users.email %>
</div>
<div class="edit-password">
<label for="password">Password</label>
<%= f.password_field :password,:id => 'first_name',:value => @users.password %>
</div>
<div class="edit-confirm">
<label for="Address">Password again</label>
<%= f.password_field :password_confirmation,:id => 'first_name' %>
</div>
<div class="edit-telephone">
<label for="phone">Phone no</label>
<%= f.telephone_field :tel_no,:id => 'first_name',:value => @users.tel_no %>
</div>
<div class="edit-address">
<label for="Address">Address</label>
<%= f.text_area :address,:class => 'address_text',:value => @users.address %>
<textarea id="first_name"></textarea>
</div>
<div class="edit-submit">
<%= f.submit 'Update Data',:class => 'btn btn-success' %>
</div>
</div>
<% end %>
</div>
</center>
</div>
</div>
<% end %>
controller/homes_controller.rb
class HomesController < ApplicationController
before_filter :authenticate_admin!,only: [:admin]
def index
end
def admin
end
def managebooks
@books=Book.new
if params[:id]
@books=Book.find(params[:id])
@book=Book.all
end
end
def savebooks
@books=Book.new(params[:books])
if @books.save
flash[:notice]="Data has submitted successfully"
flash[:color]="valid"
redirect_to :action => 'managebooks',:id => @books.id
else
flash[:notice]="Data couldnot submitted successfully"
flash[:color]="invalid"
render 'managebooks'
end
end
def remove
@books=Book.find(params[:id])
@books.destroy
end
def books
end
def showbooks
@books=Book.all
end
def searchbooks
@books=Book.all
end
def member
@users=User.new
end
def registration
@users=User.new
end
def savedata
@users=User.new(params[:users])
if @users.save
flash[:notice]="Data has submitted successfully"
flash[:color]="valid"
redirect_to :action => 'member'
else
flash[:notice]="Data could not submitted successfully"
flash[:color]="invalid"
render 'registration'
end
end
def issuebooks
@issues=Issue.new
end
def savedissuebooks
@issues=Issue.new(params[:issues])
if @issues.save
flash[:notice]="information has saved successfully"
flash[:color]="valid"
redirect_to :action => 'member'
else
flash[:notice]="Data couldnot saved"
flash[:color]="invalid"
render 'issuebooks'
end
end
def availablebooks
@books=Book.all
end
def userissues
@issues=Issue.all
end
def magazine
@magazines=Magazine.new
end
def savemagazines
@users=User.find(params[:id])
@magazines=Magazine.new(params[:magazines])
@magazines.user_id=@users.id
if @magazines.save
flash[:notice]="Data submitted successfully"
flash[:color]="valid"
redirect_to :action => "member"
else
flash[:notice]="Data could not saved"
flash[:color]="invalid"
render 'magazines'
end
end
def magazineissue
@magazines=Magazine.all
@users=User.find @magazines.first.user_id
end
def blog
@blogs=Blog.new
end
def savecomments
@users=User.find(params[:id])
@blogs=Blog.new(params[:blogs])
@blogs.user_id=@users.id
if @blogs.save
flash[:notice]="Comment has been posted successfully"
flash[:color]="valid"
redirect_to :action => "showcomment"
else
flash[:notice]="Comment could not saved"
flash[:color]="invalid"
render 'blog'
end
end
def showcomment
@blogs=Blog.all
end
def newspaper
@newspapers=Newspaper.new
end
def savenewspaper
@users=User.find(params[:id])
@newspapers=Newspaper.new(params[:newspapers])
@newspapers.user_id=@users.id
if @newspapers.save
flash[:notice]="newspaper data saved successfully"
flash[:color]="valid"
redirect_to :action => "member"
else
flash[:alert]="Data could not saved successfully"
flash[:color]="invalid"
render 'newspaper'
end
end
def adminnewspaperissue
@newspapers=Newspaper.all
@users=User.find @newspapers.first.user_id
end
def userprofile
@users=User.find(params[:id])
end
def updatedata
@users=User.find(params[:id])
if @users.update_attributes(params(:users))
flash[:notice]="User Data has updated"
flash[:color]="valid"
redirect_to :action => 'member'
else
flash[:alert]="Data could not updated"
flash[:color]="invalid"
render 'userprofile'
end
end
end
Please check my code and let me to know where i did mistake and what should be the solution.
Aucun commentaire:
Enregistrer un commentaire