Ruby And tweenmax - ruby-on-rails

I've tried adding Tweenmax and other JavaScript libraries to my Ruby/Spree app.
But I've not been able to make it work.
I've added separate files to assets/javascripts/store
add included them in the all.js file
Yet it seems that the app doesn't run Tweenmax.
Can someone explain to me how to add Tweenmax to Ruby on Rails & Spree?

Did you try greensock-rails gem?
https://github.com/robertpataki/greensock-rails

Related

How to add JavaScript framework in rails app without adding gems?

I just want to know how to include frameworks like angularjs, polymer js, bootstrap.... Into rails app without adding corresponding gems. Reason is the gems that are available are changing and some of them are given up. So instead of gem I want to download the library files given by the vendor directly. How to add them into rails app?
You can download the framework source files/folders, add them to your vendor folder and require those. Thats essentially what those gems do. If you're looking for a more advanced approach you can look into setting up a package manager like gulp and use the direct npm packages

how to use stocktwits library?

I am building a stocktwits app in Ruby. I want to retrieve data through Stocktwits.com API. I found this library on github: https://github.com/jesseyoungmann/omniauth-stocktwits. But i am a newbie to Ruby and Rails. I am confused on how to use it. Could i use it without adding it to a Rails project? I mean i do not need to create a Rails project in order to use it. If i need to add it to Rails project, how should i add it?
Thanks in advance.
You do need to have a Rails app in order to use it. You can add it to your project by adding
gem 'omniauth-stocktwits'
to the Gemfile in the root of your project, and running bundle install.
Then follow the instructions in the README, which involves creating a file in the initialisers directory of your Rails app.

Why is there Rails.rb files all over the place?

Was digging around my Rails applications and noticed that there are rails.rb files all over the place. In my ruby gems directories like:
...gems\devise-2.0.4\lib\devise\rails.rb
...gems\cucumber-rails-1.3.0\lib\cucumber\rails.rb
...gems\railties-3.2.3\lib\rails.rb
I am assuming that there are executed whenever you issue some command like "rails xxx". So all these extra rails.rb files combine with the original rails.rb file to essentially make one big rails.rb file. Essentially, when we type in "rails xxx" it goes thru all them all?
Just looking for some confirmation PLUS a little more knowledge about this. Thanks.
The best way to understand what these rails.rb files are doing, is to read the source code.
ralties
devise
cucumber-rails
As you can see, in any library the file assumes a different scope. The common behaviour is that the file rails.rb normally contains the code required to initialize the library when loaded from a Rails project.
BTW, this has nothing to do with the script/rails command and there is no "big rails.rb" file.
The files are not generated but are simply source files of these libraries you are using.
In this case they are probably rails-related classes that either extend Rails in some way or modify it or make the library interact with Rails.
Rails is a very common framework in Ruby land so most if not all libraries will have some sort of integration with Rails.
By no means are all of those loaded when you run rails XXX but rather when your application loads these libraries their rails.rb files may be executed to provide some sort of integration with Rails.

Updating to Rails 3.2.2: How to properly move my plugin from the '/vendor' to '/lib' directory?

I am upgrading Ruby on Rails from 3.1 to 3.2.2 and I would like to know what I should make and at what I should be care in order to properly move my vendor plugin (note: it is not a gem and at this time I am not planning to make that a gem) from the directory /vendor to /lib as well as wrote in the official documentation:
Rails 3.2 deprecates vendor/plugins and Rails 4.0 will remove them completely. You can start replacing these plugins by extracting them as gems and adding them in your Gemfile. If you choose not to make them gems, you can move them into, say, lib/my_plugin/* and add an appropriate initializer in config/initializers/my_plugin.rb.
I refer mostly to the "an appropriate initializer in config/initializers/my_plugin.rb": What code should I put in that file?
More: Do you have some advice or alert on making the above process?
The initializer should contain the appropriate requires and other startup related tasks that are necessary for your plugin to work correctly. It's difficult to help you without real code examples from your app but this link should help you get started.
http://code.coneybeare.net/how-to-convert-simple-rails-23-style-plugins
The example in the link requires the plugin (now in the lib directory) and adds a module to ActiveRecord::Base.

How to override Zurb Foundation css properties using rails 3.1?

Hi there im working on a new rails app and i just started to use Foundation.
I did the installation using
rails g foundation:install
Everything is working as espected (i mean by that i can see the css in my source code, and also the visual effect of it ;p)
I just dont understand how to override the defaults proprieties of Zurb Foundation...
I saw online that im supposed to edit some foundation.css or app.css but here doesnt seems to be any file like that in my Application folder....
I did the installation by editing the gemfile then a bundle install.
cheers
and yes it works if you do your overrides on the app/assets/stylesheets/application.css
But it's better if you do it in the app/assets/stylesheets/foundation_and_overrides.scss,
also at the top of the file, there's a bunch of lines commented, with those lines you can also modify some attributes!
Option 1: Since you installed it through bundler (assuming you used something like gem 'zurb-foundation'), you won't have any files that you can edit directly. You can override and style as usual by editing app/assets/stylesheets/application.css or adding new files within the directory. I'd recommend this over modifying Zurb so you can continue receiving the benefits of being able to upgrade to newer versions of Zurb in the future without dealing with a mess.
Option 2: If you feel that you need more control over the customization and you aren't worried about the above pitfalls, you can clone/download foundation-rails and copy the files in vendor/assets to your own Rails directory of the same name. Remove zurb-foundation from your Gemfile, rebundle, and you should be able to modify the assets directly in your own project.
Option 3: Check out foundation-sass and give Compass a try. I haven't looked into it much but you should have some amount of customization through mixins.

Resources