FullCalendar Rails Assets - ruby-on-rails

I am using the fullcalendar rails gem. I just downloaded the zip file for the calendar which contains the js and css files for the fullcalendar plugin. For all the tutorials on the fullcalendar gem I have not seen anyone doenload the zip file and use these files in their code (they use the CDN links but those don't appear to be working) where is the best folder to place these zipped assets into so that I can get the desired results on my calendar?

If you use the gem you do not need download any file.
You have to:
install gem
add in the application.js file the instruction //= require fullcalendar
And to can use it.
Read the README of the gem https://github.com/bokmann/fullcalendar-rails
Because you also need moment.js

Don't install from the zip file.
Follow the instructions at https://github.com/bokmann/fullcalendar-rails#installation for installation; you will have an easy time managing the dependencies.
The steps as specified there are:
Add gem 'fullcalendar-rails' to Gemfile
Add gem 'momentjs-rails' to Gemfile if you want to use 2.1.1.0 or higher version of fullcalendar-rails gem.
Run bundle install to install the gems.
Add //= require fullcalendar (and //= require moment) in application.js
Add *= require full calendar in application.css

Related

Sprockets::FileNotFound: couldn't find file 'adminlte' with type 'application/javascript'

I followed stack overfolw's answer
to add adminlte in my rails app
it also says to add
//= require adminlte
in application.js
it works fine on local system but now when I am trying to deploy to digital ocean droplet it gives error
Sprockets::FileNotFound: couldn't find file 'adminlte' with type 'application/javascript'
My gemfile(I removed all gems except relavent) to clear the adminlte issue
source 'https://rubygems.org'
gem 'bundler', '>= 1.8.4'
gem 'pnotify-rails'
source 'https://rails-assets.org' do
gem 'rails-assets-adminlte', '2.3.3'
end
end
I normal cases we write
source 'https://rubygems.org'
gem 'pnotify-rail'
and in application.js
//= require pnotify
and don't include any file like pnotify.js manully
But in this case I instead used
source 'https://rails-assets.org' do
gem 'rails-assets-adminlte', '2.3.3'
end
and for this
//= require adminlte causing issue
From What I understand, you do not have a file named adminlte in your javascript folder.
Your app/assets/javascripts/ must have all the files that you want to require in your application.js
So if you have required adminlte, you must also have a file with the same name in your javascripts folder.
I see that you are using a theme, you might want to consider copying all the javascript and css files to the respective folders. If you have a folder to require, you could use // require_tree ./adminlte which requires all the files in that folder.
I hope this helps :)
I had the same problem, having to import adminlte on some servers and AdminLTE on others.
Just use rails-assets-admin-lte instead of rails-assets-adminlte (they're based on the same code) and import admin-lte instead of adminlte in your CSS and JS application files.

looking for twitter-bootstrap source files in rails

I have the gem "twitter-bootstrap-rails". And I want to modify some sources files (js && less). Less is importing some files but I don't see where it takes the #import "fontawesome/font-awesome"; from? I don't see them in my app/assets... || vendor/assets...
Edit the gemfile, adding to it the link to local resided gem.
gemfile:
gem 'twitter-bootstrap-rails', :path => '/home/user/git/twitter-bootstrap-rails'
Clone the twitter-bootstrap-rails gem, and issue installation of gems for your project:
$ cd /home/user/git
$ git clone https://github.com/seyhunak/twitter-bootstrap-rails.git
$ cd /your/project/path
$ bundle install
So you can edit then the bootstrap's files.
Run you app with bundler:
$ bundle exec rails s
If you want to use different versions of the javascript files than the ones that come bundled with the gem, the first step is to make sure the following isn't in your application.js:
//= require twitter/bootstrap
When you require 'twitter/bootstrap', it loads all of the individual javascript files for you. Instead, you can specify which ones you want the gem to load for you, and then you can manually require the ones that you have modified.
For example, if your modified source files were in app/assets/javascripts/bootstrap_overrides/, you would do:
//= require twitter/bootstrap/bootstrap-transition
//= require twitter/bootstrap/bootstrap-alert
//= require twitter/bootstrap/bootstrap-modal
//= require twitter/bootstrap/bootstrap-button
//= require twitter/bootstrap/bootstrap-collapse
// ... do this for the remainder of the components you wish to import from the gem
//= require bootstrap_overrides/dropdown.js
//= require bootstrap_overrides/tooltip.js
This will let you use your own modified js instead of what's supplied with the gem. The source for the versions of tooltip.js and dropdown.js included in the gem are available at the gem's github repo: https://github.com/seyhunak/twitter-bootstrap-rails
Also, since these components require jQuery to work, be sure to include them after jQuery in your application.js
Hope this helps!

How can I add the Flat UI into Rails?

Rails n00b here and I'm just wondering if anyone can help me get the DesignModo Flat UI (free) into the assets pipeline? Do I first have to download and load Bootstrap into the pipeline?
I have found a way to get Bootstrap into rails, which is fairly simple, but I added in the Flat UI files and it just seemed to screw things up. Trying to start over now.
You could use this gem
flatui-rails with javascript
Add to your Gemfile
gem 'flatui-rails'
run bundle install
Add to your application.css
*= require flat-ui
Add to your application.js
//= require flat-ui
flat-ui-rails without javascript
add to your Gemfile
gem "flat-ui-rails"
run bundle install
Add flat-ui to your application.css
*= require flat-ui
or application.css.scss
#import "flat-ui";

Sprockets can't find javascripts in flot-rails gem

I tried to use the foot-rails gem to install flot but was unsuccessful.
I added gem "flot-rails" to my gemfile and executed bundle install
I then added
//= require jquery.flot
//= require jquery.flot.resize
to my /app/assets/javascripts/application.js file
I verified that the gem installed properly (gem show flot-rails) and found that the javascripts were all in the vendor directory of the gem but my app reports
couldn't find file 'jquery.flot'
(in ...path/app/assets/javascripts/application.js:12)
I chose to just install the files manually into my assets directory but I'd like to know what's wrong with my sprockets.
Why ca't Sprockets resolve the references?
Well, don't I feel stupid.
I needed to restart the web server after bundle install

Rails Asset Pipeline: What happens when we do require in application.js

I am trying to contribute to the opensource project jquery-datatables-rails. But it puzzles me as how it works. I have basic understanding of how to create gem. It seems like the project just simplifies the path references but nothing more. The four steps listed to install are
Add to the assets group in your Gemfile:
gem 'jquery-datatables-rails'
Install the gem:
bundle install
Add the JavaScript to application.js:
//= require dataTables/jquery.dataTables
Add the stylesheets to application.css:
*= require dataTables/jquery.dataTables
But I don't understand how Rails knows where to find dataTables folder and why we use jquery.dataTables to reference the file/class. The code is easy to understand, but the file organization confuses me so much. Is there any writing on topics related to my confusion?
Thanks.
Update:
Just found this great documentation on Rails Engine: http://edgeguides.rubyonrails.org/engines.html
By default Rails asset pipeline searches for the files in app/assets/, lib/assets, and vendor/assets of the Rails application. But this gem is a Rails engine, and it adds path of its own assets to default assets paths. It has its own vendor/assets.

Resources