How do I use social-share-button gem (or any other gem for that matter) in a rails 6 web app? - ruby-on-rails-6

with all the changes in the app/asset folder. I am a little confused as to how i am supposed to follow the instructions on their github page.

Related

Using Less files in Rails

I would like to ask how to use .less files in a Rails application if they are placed under assets but in a separate folder (let's call the folder "myless") from stylesheets. Another way to term this is that the myless folder would be side by side the folders, "images", "javascript" and "stylesheets" which are under the assets folder.
How do I import them to application.css or to a .CSS file? What lines of code would I use?
Do I have to add a method in environment.rb?
What gems do I have to use?
Any insight would be superb. Note that I am fairly new to Rails and are studying different tutorials on it. The different implementations in different versions of Rails is confusing me and there's not really a clear tutorial I can find online. I am currently trying to implement a bootstrap template, this is why I ask this question. I got the JavaScript and the CSS down but realized that the template uses .less files. Help?
You can enable your app to support LESS by including the appropriate gem(s):
gem 'therubyracer'
gem 'less-rails'
Then run bundle install. Assuming you have the appropriate stylesheets included in your stylesheets manifest, you should be good to go!
There's also the rails-less-bootstrap gem if you want a simpler way of including Bootstrap in your project.
Note: it's a good idea to keep your stylesheets together. Instead of having the myless directory be on the same level as images, javascripts, and stylesheets, you should consider moving it inside of your stylesheets directory.
Hope it helps!

How to include your own css files in a rails application using bower?

I am working on a rails app and I would like to include some custom css files inside my rails application. I would like to separate out the css from bootstrap and the css that I wrote. Could I just put the custom css files inside vendor/assets/bower_components folder in my own css folder?
Is there anything else that I need to do for my css files to be picked up?
There are several ways you can achieve bower functionality in a Rails application.
Although having said that, I'm not sure about your wanting to use it on your custom.css file. The file itself will work just as well if you keep it in your app/assets/stylesheets folder, which will concatenate it to the asset pipeline
Bower-Rails
You'll may wish to consider using bower-rails, which seems to just give you the ability to use bower within your Rails app. This seems to be specifically for helping you keep your dependencies up to date:
Dependency file is bower.json in Rails root dir or Bowerfile if you
use DSL. Check out changelog for the latest changes and releases.
RailsAssets
Another amazing piece of functionality we found recently is "RailsAssets"
This works really well (we use it in production), as it keeps your dependent assets completely up to date. You can use it very simply:
#Gemfile
source https://rails-assets.org
gem 'rails-assets-BOWER_PACKAGE_NAME'
#app/assets/javascripts/application.js
//= require BOWER_PACKAGE_NAME
When running bundle update, this will then give you the ability to update your assets in line with your app!

How to include Susy sass framework with Web Essentials

I tried to make simple web solution - a hello world solution - with the susy responsive toolkit. The instructions on the susy docs say to pull the sass folder in, but the sass doesn't seem to compile.
It is possible to get susy 2.2 to work in VS w/ web essentials?
I'm using VS2013 update 3 with web essentials.
I'd really appreciate it if somebody could upload a 'hello world' working solution. And so would this guy.
Additional Info for non-VS users:
Web essentials usually 'compiles' sass into css files.
Web essentials also has a menu option to compile the sass.
Once I uncomment the import statement, the sass no longer compiles or refreshes. No error message is shown. I'm pretty sure this is a web essentials plugin or web essentials dependancy problem.
At this time, VS web exetensions probably uses a sass compiler does does not meet the susy2.1's sass 3.3+ requirement.
The sass folder in the susy2.1 project compiles okay when compiled with koala - which supports sass version 3.3.7 as of writing.
As of now there is an issue with libSass and #import not working as expected. The author notes it here and links to libSass issues here

Temporary scaffolding on rails 3

I'm new to rails and I'm actually reading a tutorial on it but unfortunately it's a very old one (2007). They talk about temporary scaffolding which is a one-line addition to a controller for example:
class StoryController < ApplicationController
scaffold :story
end
I tried it in my project but I'be got this error:
Routing Error
No route matches [GET] "/story"
Try running rake routes for more information on available routes.
I thought maybe it's because I'm running a different rails version, maybe the syntax have changed... So my question is how do we perform temporary scaffolding on rails 3.
I previously had to set config.assets.enabled to false because I had a route error.
I'm running under:
Rails 3.2.13
Windows 8 pro 32-bits
I'm very surprised to see this, because I wasn't around when Rails had this scaffold method you show. I've never heard of it before.
I searched the API documentation (and Rails source) and there is nothing like this now. Instead, there is the rails generate scaffold command. You can find more information at http://guides.rubyonrails.org/command_line.html.
As a suggestion: If you want to use a version of Rails from 2007, the tutorial you have now is fine. If you want to use a modern version, find a modern tutorial. The Ruby on Rails Guides site is good.

How do i create a gem which will generate a css file from a template

I have a set of css files which I use in almost all projects.
I would like to create a gem which has a generator inside it.
I managed to write some code using the tutorial given here http://guides.rubyonrails.org/generators.html
However i am not sure about how to move this to a gem and use a command like device install ....
There are actually two ways of doing this (and both involve a Rails Engine afaik).
You create a engine that contains a generator for your file
You create a engine that bundles the CSS file so you can require it without having it present in your code repository. (Similar to the jQuery gem).
To create an engine just follow this guide: http://edgeguides.rubyonrails.org/engines.html.
Just without the mountable option and anything you put inside your app/assets/stylesheet directory will be available through require inside your CSS manifest.
The relevant part in the guide is in 6.4 besides the general boilerplate setup you have to do.
For a generateor the same applies, you just have to put the generator in the generators directory as you would with the app and can then run it from there with the engine prefix.

Resources