Note that there are some explanatory texts on larger screens.

plurals
  1. PORails regex validations throw no method error in Heroku
    primarykey
    data
    text
    <p>I have used the following regex to validate the nic number in my rails app :</p> <pre><code>VALID_NIC_REGEX = /\A\d{9}[V|v|x|X]\z/i validates :nic, presence: true, allow_blank: true, format: { with: VALID_NIC_REGEX }, uniqueness: { case_sensitive: false } </code></pre> <p>When I test it in my local machine, everything works fine. But after uploading to heroku, it give an error while trying to save the member with a value in the nic field. Both valid and invalid values give the error. If there's no value in the nic field, it saves the member. In the heroku log, I found this error :</p> <pre><code>NoMethodError (undefined method `limit' for nil:NilClass): app/controllers/members_controller.rb:117:in `update' </code></pre> <p>So, I commented out the two validation lines and uploaded the site to Heroku. Now it works. Can some one please explain this? Thank you.</p> <p>Controller update action :</p> <pre><code>def update @source = params[:source] @telfie = params[:telfie].to_i @member = Member.find(params[:id]) @tel = Array.new (1..@telfie.to_i).each do |i| @tel &lt;&lt; params[:tele][:"#{'tele'}#{i}"] end #params[:tele] = @tel if params[:commit] == 'More Numbers' @telfie = @telfie + 1 render 'edit' else if params[:commit] == 'Less Numbers' if @telfie &gt; 1 @telfie = @telfie - 1 render 'edit' else flash.now[:error] = "Can't remove all contact fields!" render 'edit' end else if @member.update_attributes(member_params) @member.tele = @tel @member.save flash[:success] = "Member #{@member.name} Successfully Updated!" if params[:commit] == 'Save Member and Add Associates' redirect_to new_associate_url(memberid: @member.id, source: "memberv" ) else if @source == "database" redirect_to database_path else redirect_to member_url(@member) end end else render 'edit' end end end end </code></pre>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload