Carrierwave keeps returning the error below when i tried to save a remote url.
photo = space.photos.build
photo.remote_image_url = photo_url
photo.save!
# NoMethodError: undefined method `gsub!' for nil:NilClass
Any ideas?
It seems like it was just an old version of the fog gem, version 0.9.0. To solve the problem just add this to your gemfile:
gem 'fog', '>= 1.11.1'
Related
I was using will_paginate for pagination on my site but as we're using Active Admin I decided to change it to kaminari to avoid any of the conflict issues between the two. I removed will_paginate from the gem file and added kaminari, restarted the rails server and ran bundle install but I'm getting errors which suggest it has not been installed properly:
undefined local variable or method `page' for <SearchController:0x007fd546587140>
Rails version: 5
Gemfile:
gem 'kaminari', '~> 0.16.3'
#gem 'will_paginate', '~>3.1.6'
Controller:
...
#properties = #properties.page(page[:params]).per(9)
Not sure what the issue is?
There is no object page in your controller...
#properties = #properties.page(page[:params]).per(9)
I think what you wanted to do was...
#properties = #properties.page(params[:page]).per(9)
I just installed the will_paginate, 3.0.7 and bootstrap-will_paginate, 0.0.10 gem and when i call the following to get my articles paginated
def index
#articles = Article.paginate(page: params[:page], per_page: 5)
end
I get the following error upon attempting to launch the localhost server
/Users/Jack/.rvm/gems/ruby-2.3.1#global/gems/activesupport-5.0.0.1/lib/active_support/i18n_railtie.rb:45:in `map': undefined method `existent' for #<String:0x007fd4a2bfa5d0> (NoMethodError)
Did you mean? extend
What's going wrong?
This was an issue with earlier version of will_paginate with Rails 5.
You need to update your will_paginate gem to use latest updated one which is:
gem 'will_paginate', '3.1.5'
This issue has been fixed with this merge:
https://github.com/mislav/will_paginate/pull/450
I am using the following commond
gem 'carrierwave'
bundle
rails generate uploader image
mount_uploader :image, ImageUploader
but it gives the errors
NoMethodError in PostsController#index
undefined method `mount_uploader' for Post:Class Extracted source
(around line #8):
line #8: mount_uploader :image, ImageUploader
end
I think your problem is you are using the wrong gem, for mongodb using mongoid ORM you should use the following gem,
gem 'carrierwave-mongoid', :require => 'carrierwave/mongoid'
If you install this you problem should get solved.
Im trying to install Kaminari pagination on rails 3 with adminpanel RailsAdmin, but I get this error:
NoMethodError in ShowsController#
undefined method `page' for # < ActiveRecord::Relation:0xaadc8d4>
Do you also have the gem "will_paginate" in use?
Check the file Gemfile.lock to see if you have this gem in use as well:
grep will_paginate Gemfile.lock
If that's the case, all you have to do is to create the file "config/initializers/kaminari.rb" and write this content on the file:
Kaminari.configure do |config|
config.page_method_name = :per_page_kaminari
end
that should fix the issue
In my case I forgot to add the kaminari gem to my Gemfile :facepalm:
Newly installed will_paginate 3.0.0
gem 'will_paginate', '~> 3.0.0', :require=>'will_paginate/data_mapper'
Running a controller query:
#tickets = Ticket.paginate(:page => params[:page], :per_page => 5,:username => #ticket.username)
Which works, pulls up all the tickets for a user and paginates in 5's if I put ?page=X where x is a page number in the url.
=will_paginate(#tickets)
in the view does not work, this results in
undefined method `will_paginate' for #<#<Class:0x000000053674c8>:0x0000000535cd48>
So will_paginate works, but not the view helper. Am I missing something? I'm using slim templating if that makes any difference. Is there some syntax change I'm missing? The documentation is simple but unhelpful beyond this point. I looked into the source, and there does not seem to be any changes, but I cannot figure why it is inaccessible
And then on tangent, this messes with an association.
=> #instance.model_belonging_to_instance.create(:text=>'test')
TypeError: can't convert nil into Integer
from /home/qx/.rvm/gems/ruby-1.9.2-p180/gems/will_paginate-3.0.0/lib/will_paginate/page_number.rb:16:in `Integer'
etc etc et al
SOLUTION:
gemfile:
gem 'will_paginate', '~> 3.0.0' # removed this, :require=>'will_paginate/data_mapper'
intializer:
require 'will_paginate'
require 'will_paginate/data_mapper'
It shows up, but if not at the top of the template, I get a
stack level too deep
error I am unable to interpret
Don't use the :require option in the Gemfile, as you already figured out; instead require "will_paginate/data_mapper" somewhere in config/application.rb, for instance after the Bundler setup.
There is a similar question with an answer that indicates that auto-requiring here is the problem. See will_paginate undefined method. The Will_paginate gem appears to work though for the question and answer.
gem 'will_paginate', '~> 3.0.0', require: %w[
will_paginate
will_paginate/data_mapper
]