Trying to add Gravatar to my app
but get "could not find generator gravtastic" on the command line
added gem 'gravtastic'
ran bundle install
Using warden (1.2.3)
Using devise (3.1.2)
Using foreigner (1.6.1)
Installing gravtastic (3.2.6)
Using hike (1.2.3)
Using jbuilder (1.0.2)
Using jquery-rails (3.0.4)
Using subexec (0.2.3)
restarted server
rails g gravtastic:install
Could not find generator gravtastic
Do you need to run a generator?
I think you just have to do:
class User < ActiveRecord::Base
include Gravtastic
gravtastic
end
The documentation doesn't mention the gravtastic generator.
Related
I have a Rails 4.2 framework and use Kaminari to paginate. Everything works great, but I want to test everything with Capybara, thus I run into the page conflict. So I wanted to rename the page_method_name of Kaminari and followed the guide from them:
$ bundle exec rails g Kaminari:config
This results in this file
app/config/initializers/kaminari_config.rb
Kaminari.configure do |config|
config.page_method_name = :plant
end
In which I simply uncommented the config.page_method_name and set it to :plant (as an example from the Kaminari docs to avoid any reserved method name conflicts for something like :kaminari_page).
Then I adjusted the appropriate controller to
def index
#q = Interaction.published.order(updated_at: :desc).limit(200).ransack(params[:q])
#selection = #q.result
#interactions = Kaminari.paginate_array(#selection).plant(params[:page]).per(10)
respond_to do |format|
format.html
format.js
end
end
I restarted everything and got this error when visiting the
undefined method `plant' for #Kaminari::PaginatableArray:0x00005568fb42ba30
Gemfile.lock:
kaminari (1.2.1)
activesupport (>= 4.1.0)
kaminari-actionview (= 1.2.1)
kaminari-activerecord (= 1.2.1)
kaminari-core (= 1.2.1)
kaminari-actionview (1.2.1)
actionview
kaminari-core (= 1.2.1)
kaminari-activerecord (1.2.1)
activerecord
kaminari-core (= 1.2.1)
kaminari-core (1.2.1)
I was then googling around and also added require 'kaminari' (which does not make so much sense, because I did not get the uninit constant error) and also included the Kaminari configure section into the class Application < Rails::Application inside config/application.rb.
Nothing worked, always the same error.
You show your files location as app/config/initializiers/kaminari_config.rb. If that is the actual location of your file it fully explains why the method doesn't exist. The location should be app/config/initializers/kaminari_config.rb. With the location you specified it wouldn't be automatically loaded when the app starts.
If the location you showed is just a type then that wouldn't be the cause, but if you didn't include Capybara into the global object, which you shouldn't be doing anyway, then you wouldn't have a name collision. Current versions of Capybara issue a warning when you do include it into the global object specifically for this reason.
Also is there any reason you're grabbing all the results and then paging them, rather than using the page (or plant) and per scopes that would be defined on Interaction?
I have this code which works fine (!!! without the first line "task..."!!!) in console. It creates events in DB. However no luck when running the rake (rake fetch_ttt):
task :fetch_ttt => :environment do
require 'nokogiri'
require 'open-uri'
url = "http://www.example.com"
doc = Nokogiri::HTML(open(url))
doc.css("#eventrow").each do |item|
unless Event.find_by_name(item.at_css("a").text).present?
Event.create(
:start_time => item.at_css("#eventdate").text,
:name => item.at_css("a").text,
:url => item.at_css("a")[:href]
)
end
end
end
This is the trace (not much in dry run neither):
** Invoke fetch_ttt (first_time)
** Invoke environment (first_time)
** Execute (dry run) environment
** Execute (dry run) fetch_ttt
It has been fine couple hours ago. Since then I did a "bundle update", made some DB migrations, edited associations. I tried rolling back migrations and removed model association changes with no luck. I suspect the gems.
Below the 3 gems I rolled back to the previous versions to see if they are responsible but not. And the full diff.
old ones:
gem 'rake', '10.5.0'
gem 'http', '0.9.8'
gem 'ipaddress', '0.8.2'
full diff:
- bcrypt (3.1.10)
+ bcrypt (3.1.11)
- carrierwave (0.10.0)
+ carrierwave (0.11.2)
+ mimemagic (>= 0.3.0)
- concurrent-ruby (1.0.0)
+ concurrent-ruby (1.0.2)
- devise (3.5.6)
+ devise (4.1.1)
- railties (>= 3.2.6, < 5)
+ railties (>= 4.1.0, < 5.1)
- thread_safe (~> 0.1)
- domain_name (0.5.20160128)
+ domain_name (0.5.20160310)
- excon (0.45.4)
+ excon (0.49.0)
- excon (~> 0.45)
+ excon (~> 0.49)
****lots of stuff related to "fog" gem
- http (0.9.8)
+ http (0.9.9)
- ipaddress (0.8.2)
+ ipaddress (0.8.3)
- mime-types (2.99)
- mini_magick (4.4.0)
+ mime-types (2.99.1)
+ mimemagic (0.3.1)
+ mini_magick (4.5.1)
mini_portile2 (2.0.0)
- minitest (5.8.4)
- multi_json (1.11.2)
+ minitest (5.9.0)
+ multi_json (1.12.0)
- rails_stdout_logging (0.0.4)
+ rails_stdout_logging (0.0.5)
- responders (2.1.1)
+ responders (2.2.0)
- sprockets (3.5.2)
+ sprockets (3.6.0)
- sprockets-rails (3.0.1)
+ sprockets-rails (3.0.4)
- tilt (2.0.2)
+ tilt (2.0.4)
Rails 4.2.5, Ruby 2.1.4, I am on C9 IDE. But doesn't work on heroku neither.
UPDATE
reverted back to rake 10.5.0 (and did grep rake Gemfile.lock) now in the console I only get:
<Rake::Task fetch_ttt => [environment]>
scraping doesn't run at all :(
I don't think there's enough info here to give a definitive answer, but I would start by investigating the root cause for why it isn't working on heroku.
For example, does the rake task run at all? How do you know?
If so, do heroku run rails c and try doing the sequence of code yourself. Inspect the database records before and after you expect a chance. What happened?
If it didn't run, what type of output did you get? heroku logs can also be helpful.
One other little tip, it's possible to use byebug with heroku logs -t. Although I only recommend this in your staging environment and only if you're willing to clean up the git history afterwards.
In short, my answer is I would solve it by debugging more directly. Hope this helps.
outcommented
#require 'nokogiri'
#require 'open-uri'
and now it works. Even with rake 11.1.2
Resource form contents:
form do |f|
f.inputs do
f.input :name
end
f.actions
end
I am using Rails 5 beta 3, here is Gemfile contents:
# Backend
gem 'activeadmin', github: 'activeadmin/activeadmin', branch: 'master'
Gemfile.lock contents:
GIT
remote: git://github.com/activeadmin/activeadmin.git
revision: f7483e3b8fcd74437b03c18fb658dac62a9fc62e
branch: master
specs:
activeadmin (1.0.0.pre2)
arbre (~> 1.0, >= 1.0.2)
bourbon
coffee-rails
formtastic (~> 3.1)
formtastic_i18n
inherited_resources (~> 1.6)
jquery-rails
jquery-ui-rails
kaminari (~> 0.15)
rails (>= 3.2, < 5.0)
ransack (~> 1.3)
sass-rails
sprockets (< 4)
Even attribute is included in permitted params:
permit_params :name
it's missing in params when I submit empty value and as a result name is not updated. Non-empty values work OK.
Same with select boxes.
After error occured, I tried to update Active Admin with:
bundle update activeadmin
but error still remains.
I tested it on simple rails form (generated by scaffold command) and formtastic outside of Active Admin resource, both options work, so it seems to be Active Admin problem.
Here is how I checked params content (also checked logs/development.log):
controller do
def update
abort params.inspect
end
end
So name is not presented even at this moment.
I posted issue here but no feedback till now.
Since you are using rails5.0.0beta2, you are probably also using rack 2.0.0.alpha.
This is caused by a bug in rack.
Until rack2.0.0 become stable, you can solve this bug by adding to the Gemfile:
gem 'rack', github: 'rack/rack'
I develop a new application and I want to transfer users from old one. I'd like to let them to use their own old password in new app.
OLD_APP:
config.encryptor = :authlogic_sha512
config.pepper = "xxx"
devise (1.1.7)
bcrypt-ruby (~> 2.1.2)
warden (~> 1.0.2)
NEW_APP:
devise (2.2.3)
bcrypt-ruby (~> 3.0)
orm_adapter (~> 0.1)
railties (~> 3.1)
warden (~> 1.2.1)
BCrypt
without pepper (config.pepper line left commented)
I used some solutions such as:
Converting existing password hash to Devise
but unfortunately it doesn't works.
My questions is how I could transform SHA512 hash (with salt) to BCrypt (without salt) ?
Whether anybody came across on this issue ?
Thanks.
I just upgraded my Rails site from Rails 2 to Rails 3.2.
On my old controller I had:
class Foo::BarController < ApplicationController
layout nil
...
end
However now that I upgraded to Rails 3 it seems I need to change that to:
layout false
The documentation on Rails Guides claims that layout nil should work fine:
Layout declarations cascade downward in the hierarchy ...
class OldPostsController < SpecialPostsController
layout nil
I have the following relevant gems in my Gemfile.lock
GEM
actionpack (3.2.6)
activemodel (= 3.2.6)
activesupport (= 3.2.6)
builder (~> 3.0.0)
erubis (~> 2.7.0)
builder (3.0.0)
erubis (2.7.0)
haml (3.1.6)
jquery-rails (2.0.2)
railties (>= 3.2.0, < 5.0)
Is this a documented change somewhere, or is it a related gem monkey patching something?
The API explains it like this:
If the specified layout is:
a string: the string is the template name
a symbol: call the method specified by the symbol, which will return the template name
false: there is no layout
true: raise an ArgumentError
nil: force default layout behavior with inheritance
So the meaning of nil changed from no layout to "force default layout behavior with inheritance". Seems the explanation in Rails Guides is incorrect.