dimanche 30 septembre 2018

How to handle optimistic locking in case of updated_all?

I am trying to implement the Optimistic Locking for Race Condition. For that, I added an extra column lock_version in the Product: Model through migration.

Product: Model's new field:

#  lock_version                       :integer(4)      default(0), not null

Passing lock_version in Product: Model:

 attr_accessible :lock_version

When I try to save! Optimistic Locking is working. Records, updated_at and lock_version are getting an update.

However, in the existing source code, we are using updated_all, which does not update the updated_at and lock_version. So optimistic locking is not working. Please suggest, how to implement optimistic for updated_all

Product.where(:id => self.id).update_all(attributes)
      self.attributes = attributes

samedi 29 septembre 2018

Ruby on Rails 1.9.3 - Through View model is not getting update after adding one extra field to model

I am trying to implement the Optimistic Locking for Race Condition. For that, I added an extra column lock_version in the Product: Model through migration. And passing to through attr_accessible :lock_version. I am able to update model through the rails console, however, through View I am not able to update the model.

Product: Model's new field:

#  lock_version                       :integer(4)      default(0), not null

Passing lock_version in Product: Model:

 attr_accessible :lock_version

Pass it as hidden_field in View/edit:

form.hidden_field :lock_version

Product: Model Controller:

 def update
   ...
  @product.update_with_conflict_validation(params[:car])
 end

Inside Product: Model:

  def update_with_conflict_validation(*args)
    update_attributes(*args)
  rescue ActiveRecord::StaleObjectError
    errors.add :base, "This record changed while you are editing."
    false
  end

I am using Ruby Version

Loading development environment (Rails 3.2.22.4)
irb(main):001:0> RUBY_VERSION
=> "1.9.3"

Please let me know why I am not able to update model through UI/View, however, able to update through rails console.

Reference: https://www.youtube.com/watch?v=dcfP37d8-ZI

How to overcome no method error "undefined method "each" for nil:nilclass" in ruby on rails?

I am doing department store automation project in rails for the first time. I am having an error and I don't know how to overcome it, Please help me out

I have taken a screenshot of the error here

Code:

<html>
<head>
<script type="text/javascript">
    function editable( i) {
        document.getElementById("cancel"+i).disabled = false;
        document.getElementById("upd"+i).disabled = false;
        document.getElementById("edit"+i).disabled = true;
        document.getElementById("doorno"+i).readOnly = false;
        document.getElementById("streetName"+i).readOnly = false;
        document.getElementById("landmark"+i).readOnly = false;
        document.getElementById("city"+i).readOnly = false;
        document.getElementById("state"+i).readOnly = false;
        document.getElementById("pincode"+i).readOnly = false;
        document.getElementById("phoneNo"+i).readOnly = false;
        document.getElementById("altphoneNo"+i).readOnly = false;
    }
    function nonedit( i) {
        document.getElementById("cancel"+i).disabled = true;
        document.getElementById("edit"+i).disabled = false;
        document.getElementById("upd"+i).disabled = true;
        document.getElementById("doorno"+i).readOnly = true;
        document.getElementById("streetName"+i).readOnly = true;
        document.getElementById("landmark"+i).readOnly = true;
        document.getElementById("city"+i).readOnly = true;
        document.getElementById("state"+i).readOnly = true;
        document.getElementById("pincode"+i).readOnly = true;
        document.getElementById("phoneNo"+i).readOnly = true;
        document.getElementById("altphoneNo"+i).readOnly = true;
    }
</script>
</head>
<body>
<div class="container">
<form name="searchSupplier" method="get" action="updSupAction">
<center>
    <table style="width:100%">
        <tr>
            <th><b>Supplier Id</b></th>
            <th><b>Supplier Name</b></th>
            <th><b>Supplier Type</b></th>
            <th><b>GSTIN</b></th>
            <th><b>Door No</b></th>
            <th><b>Street Name</b></th>
            <th><b>Landmark</b></th>
            <th><b>City</b></th>
            <th><b>State</b></th>
            <th><b>Pincode</b></th>
            <th><b>Phone Number</b></th>
            <th><b>Alternative Phone Number</b></th>
            <th><b>Options</b></th>
        </tr>

        <% for x in @sup %>
        <tr>
        <td><input type="text" name="Sid" style="color:black;" value="<%= x.Sid %>" readonly></td>
        <td><%= x.Sname %></td>
        <td><%= x.Stype %></td>
        <td><%= x.GSTIN %></td>
        <!--<td>Your name is <input type="text" value="SAM" readonly="readonly" /></td>-->
        <td><font color="blue"><input type="text" id="<%= "doorno#{@count}" %>" name="doorno" value="<%= x.DoorNo %>" readonly></font></td>
        <td><font color="blue"><input type="text" id="<%= "streetName#{@count}" %>" name="streetName" value="<%= x.StreetName %>" readonly></font></td>
        <td><font color="blue"><input type="text" id="<%= "landmark#{@count}" %>" name="landmark" value="<%= x.Landmark %>" readonly></font></td>
        <td><font color="blue"><input type="text" id="<%= "city#{@count}" %>" name="city" value="<%= x.City %>" readonly></font></td>
        <td><font color="blue"><input type="text" id="<%= "state#{@count}" %>" name="state" value="<%= x.State %>" readonly></font></td>
        <td><font color="blue"><input type="text" id="<%= "pincode#{@count}" %>" name="pincode" value="<%= x.Pincode %>" readonly></font></td>
        <td><font color="blue"><input type="text" id="<%= "phoneNo#{@count}" %>" name="phoneNo" value="<%= x.PhoneNo %>" readonly></font></td>
        <TD><font color="blue"><input type="text" id="<%= "altphoneNo#{@count}" %>" name="altphoneNo" value="<%= x.AlternativePhoneNo %>" readonly></font></TD>
        <td>
        <input type="button" class="registerbtn" name="edit" id="<%= "edit#{@count}" %>" value="EDIT" onclick="editable(<%= @count %>)"><br><br>
        <input type="button" class="registerbtn" name="cancel" id="<%= "cancel#{@count}" %>" value="CANCEL" disabled="true" onclick="nonedit(<%= @count %>)"><br><br>
        <button type="submit" class="registerbtn" name="upd" id="<%= "upd#{@count}" %>" disabled="true" value="UPDATE">UPDATE</button>
        </td>
        </tr><p hidden="true">
        <%= @count=@count+1 %></p>
        <% end %>
    </table>
    </form><a href="Supplier">back</a>
</div>
</body>
</html>

Kindly help me in correcting my code and this view page is for showing the data of supplier and updating it.

vendredi 28 septembre 2018

twitter clone - trying to show the users username next to their tweet on tweets index - devise

I'm trying to create a twitter clone. I'm at the point where a user can post a tweet and it shows the content and the time it was posted. However i want it so the username is also next to the tweet of whoever tweeted it. i'm unsure how to do this as the error is currently 'Couldn't find User without an ID' in my tweet controller create method. I'm also not sure of the syntax to display the username in index.html.erb. thanks.

class TweetsController < ApplicationController

  def index
    @tweets = Tweet.all.order("created_at DESC")
    @tweet = Tweet.new
    # @user = User.find(params[:id])
  end

  def show
    @tweet = Tweet.find(params[:id])
  end

  def new
    # @tweet = Tweet.new
  end

  def create
    @user = User.find(params[:id])
    @tweet = Tweet.new(tweet_params)
    @tweet.user = @user
    if @tweet.save
    redirect_to tweets_path
  end
  end

  def edit
    @tweet = Tweet.find(params[:id])
  end

  def update
    @tweet = Tweet.find(params[:id])
    @tweet.update(tweet_params)
    redirect_to tweets_path
  end

  private
  def tweet_params
    params.require(:tweet).permit(:user_id,:content)
  end
end
<h1>TWEETS</h1>

<%# @users.each do |user| %>
<%#= user.username %>
<%# end %>

<%= simple_form_for @tweet, id: "form-submit" do |f| %>
   <%= f.input :content, label: "Tweet" %>
   <%= f.button :submit, class: "btn btn-danger" %>
   <% end %>

   <br>

<% @tweets.each do |tweet|  %>
  <ul>
    <li>
      <%= tweet.created_at.strftime("%B %d %Y, %l:%M%P") %> <br>
      <%= tweet.content %>
      <%#= tweet.user.username %>
    <%#= tweet.user.username %>
    </li>
  </ul>
<% end %>

Q: Rails install suddenly requires concurrent-ruby gem and fails

After a system upgrade to macOS 10.14 I am suddenly unable to install Rails 3.2.5 on Ruby 1.8.7, since a new gem is required now: Concurrent-ruby.

I was able to install and use this system on macOS 10.13. Why is concurrent-ruby suddenly a requirement? How can I find a way to get on without it?

jeudi 27 septembre 2018

Rails server fails to load gems on startup

So I'm trying to resurrect an old rails application and hitting a hard roadblock. The previous maintainers are MIA and a skeleton README is the only tool I have in my arsenal. The app uses haml templates and unicorn as its webserver, running on ruby-1.9.3p392 and rails-3.2.18. Before diving into the problem, I'd like to disclose that the problem statement is not entirely specific (this might be attributed to my limited rails knowledge), in this light, what I'm asking for here is more a guide to help with diagnosing the issue and possible hotspots. That being said, here's my problem, the application won't start up. This is the error I get when booting up the app through ye ol' rails s:

=> Booting Unicorn
=> Rails 3.2.18 application starting in development on http://0.0.0.0:3000
=> Call with -d to detach
=> Ctrl-C to shutdown server
listening on addr=0.0.0.0:3000 fd=10
worker=0 spawning...
master process ready
worker=0 spawned pid=18424
worker=0 ready

Started GET "/" for 127.0.0.1 at 2018-09-27 20:07:55 +0200
Processing by ThingsController#index as HTML
Completed 401 Unauthorized in 5.5ms

Started GET "/users/sign_in" for 127.0.0.1 at 2018-09-27 20:07:55 +0200
Processing by Devise::SessionsController#new as HTML
  Rendered devise/sessions/new.html.haml within layouts/application (15.8ms)
Completed 500 Internal Server Error in 111.1ms

ActionView::Template::Error (undefined method `control_group' for #<ActionView::Helpers::FormBuilder:0x005579119e0270>):
    7:         = link_to icon_tag("#{provider}-sign") + " Sign in with #{provider.to_s.titleize}", omniauth_authorize_path(resource_name, provider), :class => 'btn btn-primary' 
    10:     = f.control_group :email do |f|
=> 1
  app/views/devise/sessions/new.html.haml:10:in `block in _app_views_devise_sessions_new_html_haml___1294862598904358005_46989231850520'
  app/views/devise/sessions/new.html.haml:2:in `_app_views_devise_sessions_new_html_haml___1294862598904358005_46989231850520'

  Rendered /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/actionpack-3.2.18/lib/action_dispatch/middleware/templates/rescues/_trace.erb (0.8ms)
  Rendered /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/actionpack-3.2.18/lib/action_dispatch/middleware/templates/rescues/_request_and_response.erb (1.0ms)
  Rendered /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/actionpack-3.2.18/lib/action_dispatch/middleware/templates/rescues/template_error.erb within rescues/layout (8.8ms)


Queue the skeleton README, I then attempt to try to run the application through unicorn using unicorn -p 3000 -c ./config/unicorn.rb -d, but no luck (these errors are on server startup):

{:unicorn_options=>{:listeners=>[], :config_file=>"./config/unicorn.rb"},
 :app=>
  #<Proc:0x00558b08705538@/home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/unicorn-4.6.3/lib/unicorn.rb:43 (lambda)>,
 :daemonize=>false}
I, [2018-09-27T19:30:34.480829 #16886]  INFO -- : Refreshing Gem list
Exception `LoadError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/1.9.1/rubygems/custom_require.rb:36 - cannot load such file -- bundler/setup
Exception `LoadError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/1.9.1/rubygems/custom_require.rb:36 - cannot load such file -- rubygems/source
Exception `LoadError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/1.9.1/rubygems/custom_require.rb:63 - cannot load such file -- rubygems/source
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.16.5/lib/bundler/rubygems_integration.rb:590 - method `gem' not defined in Module
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.16.5/lib/bundler/rubygems_integration.rb:588 - undefined method `find_spec_for_exe' for class `Module'
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.16.5/lib/bundler/rubygems_integration.rb:588 - undefined method `activate_bin_path' for class `Module'
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/1.9.1/psych/core_ext.rb:16 - method `to_yaml' not defined in Object
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/1.9.1/psych/core_ext.rb:29 - method `yaml_as' not defined in Module
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/1.9.1/psych/deprecated.rb:79 - undefined method `to_yaml_properties' for class `Object'
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `expansions' not defined in Class
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `expansions' not defined in Class
Exception `TypeError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/object/duplicable.rb:111 - can't copy BigDecimal
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `valid_options' not defined in Class
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `macro' not defined in Class
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `valid_options' not defined in Class
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `valid_options' not defined in Class
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `macro' not defined in Class
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `valid_options' not defined in Class
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `macro' not defined in Class
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `valid_options' not defined in Class
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `macro' not defined in Class
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `valid_options' not defined in Class
Using Ext extension for JSON.
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `middleware_stack' not defined in Class
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `_layout_conditions' not defined in ActionController::Base
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `_layout' not defined in ActionController::Base
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `_validators' not defined in Class
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `reflections' not defined in Class
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `_save_callbacks' not defined in Class
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `_validate_callbacks' not defined in Class
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `_accessible_attributes' not defined in Class
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `_active_authorizer' not defined in Class
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `_create_callbacks' not defined in Class
Type application/vnd.ms-fontobject already registered as a variant of application/vnd.ms-fontobject.
Type application/vnd.ms-word.document.macroEnabled.12 already registered as a variant of application/vnd.ms-word.document.macroenabled.12.
Type application/vnd.ms-word.template.macroEnabled.12 already registered as a variant of application/vnd.ms-word.template.macroenabled.12.
Type multipart/x-parallel already registered as a variant of multipart/parallel.
Type text/plain already registered as a variant of text/plain.
Type video/vnd.dlna.mpeg-tts already registered as a variant of video/vnd.dlna.mpeg-tts.
Exception `LoadError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/dependencies.rb:251 - cannot load such file -- posix/spawn
Exception `LoadError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/dependencies.rb:240 - cannot load such file -- posix/spawn
Exception `LoadError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.16.5/lib/bundler/runtime.rb:81 - cannot load such file -- phantomjs_polyfill-rails
Exception `LoadError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.16.5/lib/bundler/runtime.rb:81 - cannot load such file -- wkhtmltopdf-binary
Exception `LoadError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.16.5/lib/bundler/runtime.rb:95 - cannot load such file -- wkhtmltopdf/binary
Exception `LoadError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/dependencies.rb:251 - cannot load such file -- active_support/proxy_object
Exception `LoadError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/dependencies.rb:240 - cannot load such file -- active_support/proxy_object
Exception `LoadError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/dependencies.rb:251 - cannot load such file -- action_view/dependency_tracker
Exception `LoadError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/dependencies.rb:240 - cannot load such file -- action_view/dependency_tracker
Exception `LoadError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/dependencies.rb:251 - cannot load such file -- cache_digests
Exception `LoadError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/dependencies.rb:240 - cannot load such file -- cache_digests
Exception `LoadError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/dependencies.rb:251 - cannot load such file -- oily_png
Exception `LoadError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/dependencies.rb:240 - cannot load such file -- oily_png
Exception `LoadError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.16.5/lib/bundler/runtime.rb:81 - cannot load such file -- binding_of_caller
Exception `LoadError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.16.5/lib/bundler/runtime.rb:81 - cannot load such file -- capistrano
Exception `LoadError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.16.5/lib/bundler/runtime.rb:81 - cannot load such file -- capistrano-bundler
Exception `LoadError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.16.5/lib/bundler/runtime.rb:95 - cannot load such file -- capistrano/bundler
Exception `LoadError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.16.5/lib/bundler/runtime.rb:81 - cannot load such file -- capistrano-rails
Exception `LoadError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.16.5/lib/bundler/runtime.rb:95 - cannot load such file -- capistrano/rails
Exception `LoadError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.16.5/lib/bundler/runtime.rb:81 - cannot load such file -- capistrano-rvm
Exception `LoadError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.16.5/lib/bundler/runtime.rb:95 - cannot load such file -- capistrano/rvm
Exception `LoadError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.16.5/lib/bundler/runtime.rb:81 - cannot load such file -- sqlite3
Exception `LoadError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.16.5/lib/bundler/runtime.rb:81 - cannot load such file -- intellij-coffee-script-debugger
Exception `LoadError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.16.5/lib/bundler/runtime.rb:95 - cannot load such file -- intellij/coffee/script/debugger
Exception `LoadError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.16.5/lib/bundler/runtime.rb:81 - cannot load such file -- better_errors
Exception `LoadError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.16.5/lib/bundler/runtime.rb:81 - cannot load such file -- guard-jasmine
Exception `LoadError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.16.5/lib/bundler/runtime.rb:95 - cannot load such file -- guard/jasmine
Exception `LoadError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.16.5/lib/bundler/runtime.rb:81 - cannot load such file -- jasmine-rails
Exception `LoadError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.16.5/lib/bundler/runtime.rb:95 - cannot load such file -- jasmine/rails
Exception `LoadError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.16.5/lib/bundler/runtime.rb:81 - cannot load such file -- pry-rails
Exception `LoadError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.16.5/lib/bundler/runtime.rb:95 - cannot load such file -- pry/rails
Exception `LoadError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.16.5/lib/bundler/runtime.rb:81 - cannot load such file -- quiet_assets
Exception `LoadError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.16.5/lib/bundler/runtime.rb:81 - cannot load such file -- rspec-rails
Exception `LoadError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/bundler-1.16.5/lib/bundler/runtime.rb:95 - cannot load such file -- rspec/rails
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `_layout_conditions' not defined in ActionMailer::Base
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `_layout' not defined in ActionMailer::Base
Exception `LoadError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/dependencies.rb:251 - cannot load such file -- fast_xs
Exception `LoadError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/dependencies.rb:240 - cannot load such file -- fast_xs
Exception `ArgumentError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/1.9.1/psych/scalar_scanner.rb:91 - invalid value for Integer(): "<<"
Exception `EOFError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/newrelic_rpm-3.5.3.25/lib/new_relic/local_environment.rb:112 - end of file reached
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `_helpers' not defined in Class
Exception `LoadError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/dependencies.rb:469 - cannot load such file -- devise/mailer_helper.rb
Exception `LoadError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/dependencies.rb:363 - cannot load such file -- devise/mailer_helper.rb
Exception `LoadError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/dependencies.rb:317 - Missing helper file helpers/devise/mailer_helper.rb
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `_layout' not defined in Devise::Mailer
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `_routes' not defined in Class
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `_validators' not defined in Class
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `reflections' not defined in Class
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `_save_callbacks' not defined in Class
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `_create_callbacks' not defined in Class
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `_update_callbacks' not defined in Class
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `_validate_callbacks' not defined in Class
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `_validation_callbacks' not defined in Class
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `_accessible_attributes' not defined in Class
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `_active_authorizer' not defined in Class
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `_initialize_callbacks' not defined in Class
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `_destroy_callbacks' not defined in Class
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `nested_attributes_options' not defined in Class
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `observed_classes' not defined in ThingObserver
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `_validators' not defined in Class
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `reflections' not defined in Class
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `_save_callbacks' not defined in Class
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `_create_callbacks' not defined in Class
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `_update_callbacks' not defined in Class
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `_validate_callbacks' not defined in Class
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `_accessible_attributes' not defined in Class
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `_active_authorizer' not defined in Class
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `observed_classes' not defined in ProductObserver
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `_validators' not defined in Class
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `reflections' not defined in Class
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `_save_callbacks' not defined in Class
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `_accessible_attributes' not defined in Class
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `_active_authorizer' not defined in Class
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `_validate_callbacks' not defined in Class
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `observed_classes' not defined in ThingUserObserver
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `_create_callbacks' not defined in Class
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `middleware_stack' not defined in Class
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `_routes' not defined in Class
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `_validators' not defined in Class
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `_validation_callbacks' not defined in Class
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `_validate_callbacks' not defined in Class
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `reflections' not defined in Class
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `_save_callbacks' not defined in Class
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `_update_callbacks' not defined in Class
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `_create_callbacks' not defined in Class
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `_accessible_attributes' not defined in Class
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `_active_authorizer' not defined in Class
Exception `NameError' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activesupport-3.2.18/lib/active_support/core_ext/module/remove_method.rb:4 - method `default_scopes' not defined in Class
{:inner_app=>VPNPricing::Application}
I, [2018-09-27T19:30:43.556969 #16886]  INFO -- : listening on addr=0.0.0.0:3000 fd=10
Exception `PG::Error' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activerecord-3.2.18/lib/active_record/connection_adapters/postgresql_adapter.rb:365 - connection is closed
Exception `PG::Error' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activerecord-3.2.18/lib/active_record/connection_adapters/postgresql_adapter.rb:365 - connection is closed
Exception `PG::Error' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activerecord-3.2.18/lib/active_record/connection_adapters/postgresql_adapter.rb:365 - connection is closed
I, [2018-09-27T19:30:43.565426 #16886]  INFO -- : master process ready
Exception `PG::Error' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activerecord-3.2.18/lib/active_record/connection_adapters/postgresql_adapter.rb:365 - connection is closed
I, [2018-09-27T19:30:43.574812 #16922]  INFO -- : worker=0 ready
Exception `PG::Error' at /home/ntokozo/.rbenv/versions/1.9.3-p392/lib/ruby/gems/1.9.1/gems/activerecord-3.2.18/lib/active_record/connection_adapters/postgresql_adapter.rb:365 - connection is closed
I, [2018-09-27T19:30:43.577404 #16926]  INFO -- : worker=1 ready
I, [2018-09-27T19:30:43.581068 #16930]  INFO -- : worker=2 ready

Any guidance or pointers would be appreciated :).

mercredi 26 septembre 2018

How do I filter records by locale using gem mobility?

I have a table mobility_string_translations, but I do not understand how to get to it.

Now I have three records. Two records in German and one in Spanish. I want to get only those records that are in German.

this not working:

all_de_posts = Post.i18n.find_by(locale: :de)

lundi 24 septembre 2018

How to display map using geocode

My Script is

<script type="text/javascript">
 var lat = <%= @town.latitude %>, 
 lon = <%= @town.longitude %>,
 map;
function initialize() {
  var myOptions = {
  center: new google.maps.LatLng(lat, lon)
};
   map = new google.maps.Map(document.getElementById('map_canvas'),
    myOptions);
}
 google.maps.event.addDomListener(window, 'load', initialize);

  <script type="text/javascript" src="//maps.google.com/maps?file=api&  v=2.x&key="My api key"&libraries=places"></script>

I can fetch latitude and longitude but my map is not loading.Could anyone help me with this?

dimanche 23 septembre 2018

Not getting proper result using data-confirm-modal

I am working on a project using Rails.

I am trying to put an alert box inside a delete link.

For that, I tried using normal alert box and it was working fine, Then I used bootstrap modal, since i was using bootstrap modal code inside the loop. But it was creating modal for each loop, so i had to remove it.

Now I used Data-Confirm Modal and I followed their documentation properly, but still I am not getting any proper results.

The code is given below, Kindly give me some suggestions

 <div class="row">
  <% @user.each do |c| %>
   <div class="col-lg-3">
    <div class="card bot-card card-1">
     <div class="row">
      <div class="col-lg-8">
        <p class="d-flex align-items-center">
          <span class="green-dot"></span>
          <span class="online-text">online</span>
        </p>
       </div>
      <div class="col-lg-1">
        <%= link_to user_path(c.id), method: :delete, data: {confirm: 'Are 
      you sure?'} do %>
        <i class="fa fa-trash" aria-hidden="true" ></i>
        <%end%>
      </div>
      <div class="col-lg-1">
        <i class="far fa-clone">
        </i>
      </div>
     </div>
       <img src="assets/avatar-2.png" alt="Avatar" class="avatar" >
     <div class="card-body">
       <p class="card-title"><%= c.name %></p>
       <p class="card-text"><%= c.description %></p>
       <div class="d-flex justify-content-end card-link">
          <a href="users/#" class="card-link-1">View Details</a>
          <a href="users/<%= c.id %>" class="card-link-2">Edit</a>
        </div>
     </div>
   </div>
 </div>
</div>
<% end %>
<div class="col-lg-3">
 <div class="card card-2 d-flex align-items-center justify-content-center">
  <p>
  <a href="/users/new" class="card-link">Create user</a>
  </p>
  <p>
    <a href="/users/#" class="card-link">Create From Template</a>
   </p>
 </div>
 </div>
 </div>

vendredi 21 septembre 2018

How to create association in rails, based on condition, from parent object

Need create association in rails based on condition from parent object, like

class User < ActiveRecord::Base
  has_many :versions

here how to mention, that User must have versions, only if user is a super_admin(for example)

jeudi 20 septembre 2018

Login with Facebook In rails App without gem in rails app

I wanna create a login with facebook without using the gem. By using facebook-sdk i am getting autoResponse: accessToken and userID. Now I need to sign_up in my rails app on after success event FB.Login.

Please suggest how to achieve this?

Thanks

mercredi 19 septembre 2018

Nil Error using Ruby with Amazon Mechanical Turk in Production vs Development

I keep getting this error

property_links.rb:43:in `<main>': undefined method `each' for main:Object (NoMethodError)

when I run this ruby code using Amazon Mechanical Turk. The code was working in development returning no errors. The only thing I have changed is the last line to reflect production servers over sandbox.

properties..each do |property|
    result = @mturk.createHIT(:Title => title,
                              :Description => description,
                              :MaxAssignments => numAssignments,
                              :Reward => { :Amount => rewardAmount, :CurrencyCode => 'USD' },
                              :Keywords => keywords,
                              :HITLayoutId => LayoutID,
                              :HITLayoutParameter => [
                              {:Name => 'gis_code', :Value => properties},
                              ]
                              )
                              puts "Url: https://mturk.com/mturk/preview?groupId=#{result[:HITTypeId]}"

end

I've tried

How to add queries between tables in Ruby on Rails

I'm trying to design a complicated form. Fields also need to add data that I received with queries to other tables.

Here's what I'm trying to do.

Rad_check form is composed of username and password... When the user registers by typing username and password, the Rad_cheks table must consist of other records in the back. I was able to do some of the Radcheck model. However, I want to conditionally query the tenant_id column in the Nas table and insert it into the Rad_checks table. I've actually prepared a query for that, but I don't know how to use it.

Na.select(:tenant_id).where(Na.arel_table[:realipaddr].eq('form's real ip will be'))

Actually, I'm using the Milia gem file. However, there will be a somewhat more public form... the query I created must come in a way instead of the IP address of the request. REMOTE_IP code. This means that the user's actual IP address is tenant_id information that is equal to the IP address in the NAS table.

Help me! Please

TABLE

class CreateRadChecks < ActiveRecord::Migration[5.2]
  def change
    create_table :rad_checks do |t|
      t.integer :tenant_id
      t.string :username
      t.string :password
      t.string :attribu
      t.string :op

      t.timestamps
    end
  end
end

FORM

<%= form_with(model: rad_check, local: true) do |form| %>
  <% if rad_check.errors.any? %>
    <div id="error_explanation">
      <h2><%= pluralize(rad_check.errors.count, "error") %> prohibited this rad_check from being saved:</h2>

      <ul>
      <% rad_check.errors.full_messages.each do |message| %>
        <li><%= message %></li>
      <% end %>
      </ul>
    </div>
  <% end %>

  <div class="field">
    <%= form.label :username %>
    <%= form.text_field :username %>
  </div>

  <div class="field">
    <%= form.label :password %>
    <%= form.text_field :password %>
  </div>  

  <div class="actions">
    <%= form.submit %>
  </div>
<% end %>

MODEL

class RadCheck < ApplicationRecord
    has_one :rad_user_group, dependent: :destroy

    after_initialize :add_rad_user_group
    before_save :set_radcheck   

    def add_rad_user_group
      self.rad_user_group ||= RadUserGroup.new if self.new_record?
    end 


    def set_radcheck
      self.rad_user_group.username = username
      self.op = ":="
      self.attribu = "Cleartext-Password"
    end
end

rad_user_group table

class CreateRadUserGroups < ActiveRecord::Migration[5.2]
  def change
    create_table :rad_user_groups do |t|
      t.integer :tenant_id
      t.string :username
      t.string :groupname
      t.references :rad_check, foreign_key: true

      t.timestamps
    end
  end
end

nas table

class CreateNas < ActiveRecord::Migration[5.2]
  def change
    create_table :nas do |t|
      t.integer :tenant_id
      t.string :nasname
      t.string :realipaddr
      t.boolean :active

    end
  end
end

mardi 18 septembre 2018

User clicks on forgot password links ends up logging into application if some other user is logged in on same browser

I am using devise for authentication and using devise's default forgot password flow. When user clicks on forgot password link http://localhost:3000/users/password/edit?reset_password_token=F1XrgcSTYs5nssRZrLqf then the user logs into application if some other user is already logged into the application on same browser. I understand It happens because devise checks @current_user in session and @current_user is the one who is logged in application on that browser.

I can I change the behaviour, User who clicks should not login and should be redirected to reset password page.

lundi 17 septembre 2018

as at the touch of a button to pass its value to the function ruby

I have `

 <% for j in (1..9) %>
    <%= button_to j, {}, {class: "btn btn-secondary"}, :method => :get %>
    <% end %>

`

as when it pushes it to transfer its value to the function It function

 def show
    @some_params = params[:id]
    @file = File.open("#{Rails.root}/app/data/home_work_# 
    {@some_params}.xml", "r")
    @doc = Nokogiri::XML(@file)
    @attributes = @doc.at('subject')['id']
    @subjects = @doc.xpath("//subject")
    end

`

How to create index on single property using neo4j ruby

I am trying to create index on ActiveNode properties. when i tried with the code which is specified below , index is creating but it is throwing some warning like "The constraint option is no longer supported (Defined on Neo4j for permalink)" . How to create index on property without warning and error on nodes ?

class Neo4j
  include Neo4j::ActiveNode
  property :permalink, type: String, index: :exact 
end

And whenever i create a active node it should be automatically created after node creation , i am not appreciating functions with queries . I am using "neo4j-core" gem on ruby on rails and version , edition is below:

{
    "edition": "community",
    "version": "3.4.1"
}

Using Paper clip with Cloudfront

I uploaded images to my s3 and when i try to serve images from cloudfront, paper clip force s3_host_name/bucket/path which is not correct when using cloudfront The target is url like cdn.test.com/path

NOTICE : i am using a paperclip version 2.4.5, when i removed my s3.yml s3_host_name this is replaced with s3.amazonaws.com

:storage => :s3,
  :s3_credentials => "#{Rails.root}/config/s3.yml",
  :url => "http://cdn.test.com/images/:id/:id-:style.:extension",
  :path => "/images/:id/:id-:style.:extension",
  :default_url => "http://cdn.test.com/images/content/missing/:style.png"

and my s3.yml file has

production:
  bucket: bucket-prod
  access_key_id: XXXXXXXXXXX
  secret_access_key: XXXXXXXXXXXXX
  s3_host_name: s3-eu-west-1.amazonaws.com

how to send parameter to the action of another controller through url in rails?

how to send parameter to the action of another controller through url in rails?

controller1:

def show

@controller1.id = params[:controller1_id]

end

in the view of controller1:

%a.btn-general{:href => "/controller2/new/#{parameteroffirst.id}", :controller1_id @controller1.id, :role => "button"} Add the first

how to send controller1.id to new action of controller2?

How can i write rspec (in ruby) for login user. I have only google login in my application.

When i exec rspec for any url, it says 'Completed 401 Unauthorized in 0ms (ActiveRecord: 0.0ms)' in rspec log . I believe believe this errors are coming because i am not logged in. can anybody help me out with complete example.

dimanche 16 septembre 2018

Updating a model with validations Rails 3.2

How do I update a record in rails by making it go through all the necessary validations? As far as i know

record.update_attributes(update_hash) 

will skip all the validations. How do i update my record without skipping the validations? I'm using Rails 3.2 by the way.

samedi 15 septembre 2018

Trouble showing https modal from http page

I have a Rails 3.2.21 app, which requires the user to be logged in to do several actions (e.g. following another user).

The issue is I've switched ONLY the login & signup pages to https; the rest of the app is still http (using rack-ssl-enforcer gem to 301 redirect from http -> https on just those two pages, in case it matters). When opening up a modal via Ajax to show login or signup, it's not working. In the Rails logs it says:

WARNING: Can't verify CSRF token authenticity

And in Chrome the console says:

Failed to load https://mydomain/signup: Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://mydomain' is therefore not allowed access.

The code looks like this. Clicking the link to follow a user runs the following jQuery code:

$.ajax({ type: "GET", url: "/follow/" + $(this).data("follow-id") })

The FollowsController has before_filter :login_required, and the login_required method in ApplicationController looks like this:

def login_required redirect_to "/signup" and return end

Without the login & signup pages being https, everything works as normal. When I switched them to https, this problem crept up.

EDIT:

Already tried the solution posted here, to no avail.

RAILS_v5.2.1: Proper Rails Structure && Tricks of the Trade

Greetings to all large and small,

I've decided to try and build a website...And I'm looking at rails for the build...I have 2 questions that I'm not sure how to even ask...but here it goes

Structure?

if I were working with an object [food], I would 'generate model food', if I wanted to link more pages for [bacon,eggs,toast] would I 'generate model' for every individual object? Or would it be smarter to create pages inside [food]?

Tricks of the Trade?

now if I had 100's of different food items, whether they be models or html(I think, maybe haml) and I wanted a page for each, what is the quickest method to achieve my goal?

One last thing... would wordpress be a better format for the issue?

Thanks

Ruby OpenSSL::SSL::SSLSocket hangs for 5 minutes after second gets or eof command

I'm trying to get data from a TCP (SSL) server.

I can successfully make a connection, send a command and read the result (or at least one line of it).

This is my code:

[1] pry(main)> tcp_client = TCPSocket.new("devel1.xxxx", 1234)
=> #<TCPSocket:fd 19>
[2] pry(main)> ssl_client = OpenSSL::SSL::SSLSocket.new(tcp_client)
=> #<OpenSSL::SSL::SSLSocket:0x007fd108a46240 @context=#<OpenSSL::SSL::SSLContext:0x007fd108a46218>, @eof=false, @io=#<TCPSocket:fd 19>, @rbuffer="", @sync=true>
[3] pry(main)> ssl_client.connect
=> #<OpenSSL::SSL::SSLSocket:0x007fd108a46240 @context=#<OpenSSL::SSL::SSLContext:0x007fd108a46218>, @eof=false, @io=#<TCPSocket:fd 19>, @rbuffer="", @sync=true>
[4] pry(main)> ssl_client.puts("{'msg': 'connect', 'projectID':'e4b8de7e-d020-4b80-b60f-f2baa08eeac7', 'username': 's', 'password': 's1234'}")
=> nil
[5] pry(main)> ssl_client.eof?
=> false
[6] pry(main)> ssl_client.gets
=> "{\"msg\":\"connected\",\"connectionid\":100,\"version\":\"2.3.5\"}\r\n"
[7] pry(main)> pp Time.now
=> 2018-09-16 00:00:19 +0200
[8] pry(main)> ssl_client.eof?
[9] pry(main)> pp Time.now
=> 2018-09-16 00:05:19 +0200

After command 6 (which does return data), any command like eof? or gets takes 5 minutes time to respond. What can be causing this?

vendredi 14 septembre 2018

How to create association in rails, based on condition, from parent object

need create association in rails based on condition from parent object, like

class User < ActiveRecord::Base has_many :versions

here how to mention, that User must have versions, only if user is a super_admin(for example)

jeudi 13 septembre 2018

Common mistakes in RabbitMQ

I have two applications S-APP1 and S-APP2 and just started to use rabbitMQ with client bunny gem, so when i click(this could be more click in a minute) a button from S-APP1 then i will call publisher.rb that will publish the message into queue and read from S-APP2 - consumer.rb and put it in sidekiq for processing.

Today i just saw this link https://www.cloudamqp.com/blog/2018-01-19-part4-rabbitmq-13-common-errors.html and read this, bit confused on these lines from that link "reuse connections" and "Don’t use too many connections or channels", am i doing correctly this thing? I am using heroku to run this and using CloudAMQP addon.

publisher.rb (S-APP1)

def publish
    connection = Bunny.new( :host => ENV["AMQP_HOST"],
                            :vhost => ENV["AMQP_VHOST"],
                            :user => ENV["AMQP_USER"],
                            :password => ENV["AMQP_PASSWORD"])
    connection.start # start a communication session with the amqp server

    channel = connection.channel()

    channel.queue('order-queue', durable: true)

    exchange = channel.default_exchange

    message = { order_id: '1542' }

    # publish a message to the queue
    exchange.publish(message.to_json, routing_key: 'order-queue')

    puts " [x] Sent #{message}"
    connection.close()
end

This is my consumer part

consumer.rb (S-APP2)

connection = Bunny.new( :host => ENV["AMQP_HOST"],
                        :vhost => ENV["AMQP_VHOST"],
                        :user => ENV["AMQP_USER"],
                        :password => ENV["AMQP_PASSWORD"])

connection.start # start a communication session with the amqp server

channel = connection.channel()

queue = channel.queue('order-queue', durable: true)

puts ' [*] Waiting for messages. To exit press CTRL+C'

queue.subscribe(manual_ack: true, block: true) do |delivery_info, properties, payload|
  puts " [x] Received #{payload}"
  puts " [x] Done"

  channel.ack(delivery_info.delivery_tag, false)
  # Call worker to do refresh
  callSidekiqWorker.perform_async(payload)
end

GST Validation Regex in Coffee Script

I am working on a project in Rails and AngularJS, in which i am writing my logic in Coffee Script. As i am new in this so unable to put validation of GSTIN.

For that i defined a globle variable:-

@gstnumber = ''

and write a function :-

@validateGST = (event) ->
 @gstnumber =  '/^([0][1-9]|[1-2][0-9]|[3][0-5])([a-zA-Z]{5}[0-9]{4}[a-zA-Z]{1}[1-9a-zA-Z]{1}[zZ]{1}[0-9a-zA-Z]{1})+$/'
 if @currentUser.gst_in != @gstnumber
  return false

This Function i write for ng-keypress in HTML File :-

<input type="text" placeholder="GST No" autocomplete="off" ng-keypress="ctrl.validateGST($event)" ng-model="ctrl.currentUser.gst_in"  class="guest-input" value=""  />

I am not able to find the reason why validation is not working please help ASAP.

mercredi 12 septembre 2018

Automating an SSL Connection through an Application

I'm working on a project which currently requires the user to VPN (with credentials) into a network to search and download some files from a third party. I'm working on automating the process and one challenge I'm facing is having the application itself create an SSL connection for the task (and end the connection when done) so that I can make an API request. From my poking around, I've been able to deduce I would need a stream socket and point it to the proper end point and port (that of the third party), however I do not have the ability to manipulate anything on the side of the third party which seems to be part of the solution. I'm not even too sure if I have to manipulate anything on the side of the third party.

This area is pretty foreign to me. I'm not asking for a solution but maybe a starting point or something worth looking into. I'm not even too sure what kind of questions need answering.

I did find these which do relate to my question: python SSL connection VPN connection contained within an application

Ultimately this is a Ruby on Rails application. It has been suggested to me to keep the application VPN'd in but it is an unrealistic solution.

Thanks

mardi 11 septembre 2018

each_with_index duplicated records

first of all, excuse me if my english is not always very good.

I have a problem with the each_with_index... When I show a project, I display the offers for this project. I have to make appear a banner in third position of offers, so I use each_with_index for that.

The problem is that: if I have sixteen offers on a project, I have sixteen times the entirely list of offers, and I don't know why.

This is my code:

- @offers.each_with_index do |offer, index|
  - if !user_signed_in? && (@project.published? || @project.pending_attribution?)

    - if @offers.size >= 3 && index == 3
      = render 'offer_cta'

  - contact_bloc = user_contact_bloc(offer.user, viewer: current_user, display_contact_info: offer.display_contact_info?)
  .card.offer-card.mt-4[offer]{ class: offer_class(offer) }
    .card-header.d-flex.justify-content-between.align-items-center.border-bottom-0
      .offer-date
        %span.text-muted
          Offer filed on
          = l(offer.created_at, format: '%d/%m/%Y à %Hh%M')
        - if user_signed_in? && current_user.admin? && !offer.user.suspended_at.nil?
          ... exctera

Also, if I try this in my console, I don't have any problem...

Have you ever had this problem?

Don't hesitate to ask me if you need more information.

When running the test it is trying drop the database

bundle exec rake test TEST=test/integration/admin.rb

This is the command I am giving to run the integration test. But that file is not loading in the command prompt it showing the error:

ActiveRecord::JDBCError: com.microsoft.sqlserver.jdbc.SQLServerException: Cannot drop database "DSH_test_ontash_new" because it is currently in use

lundi 10 septembre 2018

Dynamically update iframe's title attribute using JS or Ruby?

Please note I have little JS knowledge so if there's something I can do better please let me know.

I have an iframe with three tabs that are being changed with Ruby link_to. What I am ultimately wanting to do is dynamically update the iFrames' title attribute when the links are clicked.

The original code looks like:

<div class="mobile">
 <%=link_to "one", :id => "one" %>
 <%=link_to "two", :id => "two" %>
 <%=link_to "three", :id => "three %>
 <iframe src="<%=some_url%>" width="100%;" height="100%;" aria-hidden="true", id="myFrame"><iframe>

I've done various attempts with jQuery that didn't seem to work so I've been trying the following in JS that doesn't pull in the change to the code but it's pulling up in the console:

<%=link_to "one", :id => "one", :onclick => "changer()"%>
<script>
 function changer() {
   document.getElementById("myFrame").title = "One Goes Here"
 }
</script>

No errors are present but it's not showing a change to the title.

I've also tried using:

document.getElementById('myFrame').setAttribute('title', 'One Goes Here');

No change happens.

I've also tried:

<script>
var iframe = document.getElementById("myFrame");
var iframeTitle = iframe.contentDocument.title;
document.getElementById("myFrame").onload = function() {
  var iframeTitle = document.getElementById("myFrame").contentDocument.title;
  if (document.title != iframeTitle) {
    document.title = iframeTitle;
    }
}
</script>

This just results in Uncaught TypeError: Cannot read property 'contentDocument' of null

DynamoDB table description using ruby script

I am new to Ruby on Rail with DynamoDb. So i was trying to get table description using script but nowhere i find this . Please help. I can do below by iterating through out tables as below but i wanted proper SDK use to find this.

aws dynamodb describe-table --table-name {t.name}

Configuration issue with rabbitMQ and sneakers

I have two applications sap1 and sap2 and i have been using rabbitMQ (bunny gem) for messaging, so that is working like from sap1 i will create the message and publish

sap1 (publisher app)

Gemfile

ruby 1.9.3
gem 'bunny', '~> 1.7', '>= 1.7.1'

publish.rb

def publish
    # Start a communication session with RabbitMQ
    connection = Bunny.new(:host => "123123", :vhost => "1231", :user => "123", :password => "Z7tN")
    connection.start

    # open a channel
    channel = connection.create_channel

    # declare a queue
    queue  = channel.queue("refresh-pos-menu-test", :durable => true)

    # publish a message to the default exchange which then gets routed to this queue
    values = { mac_id: 14123 }
    queue.publish(values.to_json)
    connection.close
end

sap2 (consumer app)

Gemfile

ruby 2
gem 'bunny'
gem 'sneakers'

config/initializers/sneakers.rb

require 'sneakers'
Sneakers.configure :connection => Bunny.new(:host => "123123", :vhost => "1231", :user => "123", :password => "Z7tN"), :timeout_job_after => 360

Rakefile

require 'sneakers/tasks'

app/workers/mac_worker.rb

class MacWorker
  include Sneakers::Worker
  from_queue "mac-test"

  def work(params)
     # Calling the function
  end
end

and in the console for listen doing this

 bundle exec rake sneakers:run

Here this is working, sometimes i am getting connection issue also, in the consumer app i don't want to use sneakers gem so instead i want to read message from queue with bunny and put it into sidekiq, also how to listen automatically in sidekiq?

dimanche 9 septembre 2018

Rails migration to add Primary Key to Existing table

I have a table with two columns employee_id and manager_id without primary key in Mysql. I have a setup a many-to-many relationship between Employee and Employee_Manager table.In order to update a record i need a primary key on Employee_Manager table.Hence, in rails how can generate a migration which add a comun to existing table id(primary key) and set row value for all records in existing table.

samedi 8 septembre 2018

What does ActiveRecord::Base.sanitize do?

Will sanitize deal with sql injection?

From its source code: (extracted from here)

  def sanitize(object) #:nodoc:
    connection.quote(object)
  end

sanitize uses `quote, whose source code (extracted from here) is:

  def quote(value, column = nil)
    self.class.connection.quote(value, column)
  end

I'm confused, it seems sanitize only adds quote for input, but when we are dealing with sql injection, shouldn't we do much more things like eliminating potential SQL query? What does it do and can it really SANITIZE input before executing sql query?

HTTP response from rails to spring

From Spring framework we call an api at rails framework(rails 3.2) and get the response. Suppose the API at rails looks like:

def testAPI
  # generate a result called response
  render :json => response, :status => :ok
end

Is there any way to get status code in spring? Thanks!

vendredi 7 septembre 2018

RabbitMQ with sidekiq

I have two rails applications, App1 and App2(added cloudAMQP gem), App1 is producing some message when click on a button

App1

class Publisher
   def publish
    # Start a communication session with RabbitMQ
    connection = Bunny.new(:host => "chimpanzee.rmq.cloudamqp.com", :vhost => "test", :user => "test", :password => "password")
    connection.start

    # open a channel
    channel = connection.create_channel

    # declare a queue
    queue  = channel.queue("test1")

    # publish a message to the default exchange which then gets routed to this queue
    queue.publish("Hello, everybody!")

   end
end

so in the App2 i have to consume all the messages without any button click and put that in sidekiq to process the data, but i am stuck on how can i automatically read from that queue, i know the code how to read values from queue, people are saying sneakers gem, but i am bit confused with sidekiq and sneakers, any idea of how can we do it in heroku?

jeudi 6 septembre 2018

How to get library of devise so that it can be modified like php libraries.

Getting the generated devise controller like.

class Users::SessionsController < Devise::SessionsController
   before_action :configure_sign_in_params, only: [:create]

  # GET /resource/sign_in
   def new
    # super
        #       byebug
        redirect_to  root_url   
   end

  # POST /resource/sign_in
   def create
        puts 'Login user............'        
        super
        puts '..............'

   end

  # DELETE /resource/sign_out
   def destroy
     super
   end

  # protected

  # If you have extra params to permit, append them to the sanitizer.
   def configure_sign_in_params
     devise_parameter_sanitizer.permit(:sign_in, keys: [:attribute])
   end
end

where can I get the library of devise so that I can modify it new function and do not get error of double redirect.

mercredi 5 septembre 2018

SPree Vinsol SpreeCommerce Marketing config issue

Currently i am using Spree in our Project. and i am using Spree marketing gem

There is no installation issue,gem is sucessfully installed without any error.

but when i see the marketing list in the Admin Panel.

List Page

also in the compaign page when i click on the "Sync" table no comaign will found

no record is there,i created new user ,new order but it still shows blank.

In my opinion i have a problem in my config/spree_marketing.yml file. and

development:
  gibbon_api_key: 'Entered my Mailchimp api key'
  permission_reminder: 'your_permission_reminder'
  email_type_option: true
  campaign_defaults:
    from_name: ''
    from_email: ''
    subject: 'test subject'
    language: 'english'
  contact:
    company: 'marketing'
    address1: '123'
    city: 'city'
    state: 'state'
    zip: '123456'
    country: 'country'

i entered the mailchimp id and user name in the config file>

lundi 3 septembre 2018

How does ActiveRecord::Base.sanitize work?

How does ActiveRecord::Base.sanitize work? I searched its document, it was delegated to connection.quote(source), which finally does (source):

  def quote(value, column = nil)
    self.class.connection.quote(value, column)
  end

And the comment is

Quote strings appropriately for SQL statements.

I don't understand.

  1. Where is the real implementation of the quote for sanitize? The implementation I found seems is not the real implementation.
  2. For situation based on 1=1 is always true(example), will only adding appropriate quote work?

dimanche 2 septembre 2018

reset password form validation in ruby on rails

I have an issue, I'm implementing the form validation on reset password form in ruby on rails, i don't have the email field on reset password form but email field exist in login form. when we click submit button, its show "Email must contain a valid email address.!" as well. Below the code of reset password form.

class Admin::PasswordResetsController < ApplicationController

 layout 'template'  

 VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i

def new

end

def edit
  @page_title = 'Reset Password'
  @user = User.find_by_password_reset_token!(params[:id])
end

def update
  @user = User.new(update_params)
  if @user.valid?   
          @user = User.find_by_password_reset_token!(params[:id])
          if @user.password_reset_sent_at < 2.hours.ago
            flash[:danger] = "Your Password reset link has been expired!"
            redirect_to new_admin_password_reset_path
          elsif @user.update_attributes(update_params)
            flash[:success] = "Your Password has been successfully reset!"
            redirect_to admin_login_path
          else
            render :edit
          end
 else
      render 'edit'
 end
end

def update_params
    params.require(:user).permit(:password)
end

private
      def valid_email(email)
        email.present? && (email =~ VALID_EMAIL_REGEX)
      end

end

Below the code of user model..

  class User < ApplicationRecord
       #attr_accessor :id, :email, :password

        before_create { generate_token(:auth_token) }

        has_secure_password

        VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i
        validates :email, format: { with: VALID_EMAIL_REGEX, message: 'must contain a valid email address.!' }
        #validates :password, presence: true
        #length: { minimum: 4, maximum: 16 }

        def send_password_reset
          generate_token(:password_reset_token)
          self.password_reset_sent_at = Time.zone.now
          save!
          UserMailer.password_reset(self).deliver
        end

        def generate_token(column)
          begin
            self[column] = SecureRandom.urlsafe_base64
          end while User.exists?(column => self[column])
        end

    end

Below the html code of edit.html

<% content_for :title, @page_title %>
      <div class="forgot" style="min-height:0px">
          <%= form_for @user, url: admin_password_reset_path(params[:id]), method: :patch, html: {class: "forget-form"} do |f| %>

            <% if @user.errors.full_messages.any? %>
                <% @user.errors.full_messages.reverse.each do |error_message| %>
                  <div class="alert alert-danger"><%= error_message %></div>
                <% end %>
            <% end %>


            <div class="form-group">
              <%= f.label :new_password %>
              <%= f.password_field :password, class: "form-control", placeholder: "New Password" %>
            </div>
            <div class="form-group">
              <%= f.label :password_confirmation %>
              <%= f.password_field :password_confirmation, class: "form-control", placeholder: "Confirm Password" %>
            </div>
            <div class="actions"><%= f.submit "Update Password", class: "btn btn-primary btn-block" %></div>
          <% end %>
      </div>

Below the screenshot of form.

Wrong number of arguments (given 2, expected 1) on Rails 5

I'm upgrading the project from Rails 3 project to Rails 5. Today I've encountered the strange error for me.

Now project is running on Rails 5. In project there are models User and Article. When I'm querying the User model, everything is fine:

User.all # returns all records 
User.first # returns first record

But when I'm querying the Article model, the same error appears for every query:

Article.all # ArgumentError: wrong number of arguments (given 2, expected 1)
Atricle.first # ArgumentError: wrong number of arguments (given 2, expected 1)

The project uses the devise gem, the User model was created by this gem, but the Article model is not.

The question is how I can investigate this kind of problem? What approach should I use to find the source of error?