I want to implement the social sharing feature of the articles which have been posted in my rails app. I tried following the documentation of gem 'social-share-button' where the following steps were followed :
step 1: Add //= require rails-social-share-button in app/assets/javascripts/application.js
step 2: Add *= require rails-social-share-button in app/assets/stylesheets/application.css
step 3: use the social_share_button_tag helper method in views to display the social share buttons. for e.g = rails_social_share_button_tag('Share to Facebook', url: article_path(#article), desc: #article.content)
Error:
undefined method `rails_social_share_button_tag' for #<#:0x00005574ff28ec30>
You're missing a step or two from the gem's readme. The order of the instructions in the readme is a little misleading. Did you run rails generate rails_social_share_button:install? You may also want to check the contents of the "config/initializers/rails_social_share_button.rb" file after you've run that generator.
Alternatively, you may want to use the "social-share-button" gem. It looks like the one you're using, with its longer name, is a copy of everything in shorter-named "social-share-button" gem. Also it looks like the "social-share-button" gem has been around longer and is better maintained, as it already includes one bugfix that the gem you're using does not. I'd recommend first switching gems and then running bundle install. After switching gems, you should run the generator command listed in the readme for social-share-button, check the config file as the readme recommends, and then update your views accordingly.
Related
Im setting up Ahoy gem into my application, but there are some options that I don't understand where to add.
This is what I have done currently:
1) Added gem "ahoy_matey" to my Gem File and ran Bundle install & restarted my server
2) Added //= require jquery & //= require ahoy to my application.js
3) Ran rails generate ahoy:stores:active_record and added new tables to my database by running rake db:migrate
I also have ahoy.rb in my initializers folder.
At this point I can see that ahoy is added in my application, but not sure how to do some stuff.
I want to add Ahoy.cookie_domain = :all & Ahoy.visit_duration = 1.minute, But I don't know where to add them
AND one other issue I have is that whatever page I go to is added to my Visits table (PS: I haven't added any JS or Ruby code for tracking in any pages or controller) and as I see it ,ahoy gem tracks all events/visits in my application. I only want to track events/visits on one particular action in my whole application, posts#show action and rest don't need to be added at all.
How can I achieve this?
I want to add Ahoy.cookie_domain = :all & Ahoy.visit_duration = 1.minute, But I don't know where to add them
You add them in the initializer that you created (./config/initializers/ahoy.rb). This is precisely the purpose of files in that folder: Setting configuration values for the application to use.
whatever page I go to is added to my Visits table [...] I only want to track events/visits on one particular action in my whole application
The Gem's README says:
There are three ways to track events. [...] See Ahoy.js for a complete list of features.
So start there, and take a look at ahoy.js if you need some more advanced configuration. The gem is very flexible - you just need to read the documentation and configure it as needed.
I am working on my first ever Rails 4 app and have to integrate FlatDream theme in it. So far I could not find some easy to use and decent tutorial to stylized a Rails app based on a themeForest theme. Can you guide some pointers?
Here are the steps.
Install gem "bootstrap-sass" if you don't already have it. You can install it by adding the following line to your gem file.
gem "bootstrap-sass"
bundle install
Next create a file named custom.css.scss (app/assets/stylesheets) and add the following two line to it
#import "bootstrap";
#import "bootstrap-responsive";
Next add the following to app/assets/javascript/application.js
//= require bootstrap
Now you need to convert your your css files of your theme to scss. There are converters which can help you with this. Google is your best friend here. Put the scss files image files etc at right places. If the theme uses some custom javascript you need to add it to your project in standard manner.
You are good to go.
I followed the instructions in this section:
git buttons
I want to customize the application that follows the example guide rails
I'm trying to implement some cascading style sheets, css files in my application.
I followed the video "CSS3Buttons Gem" but although the buttons work. Now I can see some nice buttons in my application, the application also returns me an error:
When I write the instruction rails g css3buttons console I get this error "Could not find generator css3buttons." Any ideas?
Why do you need to run rails g css3buttons?
In Rails 4 everything works without it:
Gemfile
#get latest available version from GitHub instead of RubyGems
gem 'css3buttons', '~> 1.0.1', git: 'https://github.com/StevenNunez/css3buttons_rails_helpers'
In root folder run bundle install
Add *= require css3buttons on top of others in 'app/assets/stylesheets/application.css'
Add <%= css3buttons_stylesheets %> in 'app/veiws/layouts/application.html.erb' in <head> section
Enjoy.
The generator you listed is to be used for Rails 3.0 apps only (ie. apps that do not use the asset pipeline that was introduced in Rails 3.1).
It doesn't look like the gem has been touched in over two years, so it's last compatibility check was for Rails 3.1. If it works in Rails 4 that's a happy bonus, but if it has problems, you may be out of luck.
I don't know if this is a ridiculous question however I am creating a website with RefineryCMS, Ruby, and Rails. I chose to speed up some things by using Twitter's Bootstrap via the less-rails-bootstrap gem. I do however need to customize some colors and such though I can't seem to locate any of the less files. I looked in the logs and see references to things such as 'twitter/bootstrap.css' though I'm not able to locate this or where the less files live.
Where are these things? Else, how to do you override the defaults?
When you complete with gem install and bundle install command , you should :
rails g bootstrap:install
This will insert some files in your app/assets dir , including bootstrap_and_overrides.css.less in app/assets/stylesheets.
You can learn more in this Railscast.
UPDATE: (Jan 25 2014): Valuable information form the comment of #Niels Abildgaard:
According to GitHub repository of less-rails-bootstrap gem, Rails generator command shoud be :
rails generate less_rails_bootstrap:custom_bootstrap
I have installed soundmanager2 within my rails application as a plug in.
after installation, I tried following command to use sound manager
rails generate sound_manager2
it shows generator not found error :(
Experimenting with rails 3 but actually wants to use with rails 2 and ruby 1.8.6
Anybody know, how it works under rails ? or is there any other way to play sound with rails app ?
Manually add the following SoundManager2 files to vendor/assets/javascripts/soundmanager2:
soundmanager2-nodebug-jsmin.js (or one of the other scripts, depending on your needs)
soundmanager2.swf
soundmanager2_debug.swf
soundmanager2_flash9.swf
soundmanager2_flash9_debug.swf
And then you should have either //= require tree . or //= require soundmanager2/soundmanager2-nodebug-jsmin in your application's JavaScript manifest file (app/assets/javascripts/application.js).
Or alternatively, just use the soundmanager-rails gem. I haven't used it myself, so I can't vouch for whether it works.
You can just drop the JavaScript and / or Flash files from the soundmanager2 download into your rails app, the plugin is just a JavaScript wrapper, you don't need it at all.
Then follow the offical Getting started guide