datatables with rails issue - ruby-on-rails

I have included this in my rails:
gem 'jquery-datatables-rails', github: 'rweng/jquery-datatables-rails'
but when I start the server I'm getting this error :
←[31mYou passed :github as an option for gem 'jquery-datatables-rails', but it is invalid.←[0m
I guess its because I'm running it locally.BTW,what will be my path if I'm running it locally?
1 more thing I followed this cast:
http://railscasts.com/episodes/340-datatables?view=asciicast
I have also tried simply this:
gem 'jquery-datatables-rails'
But after bundle install the css and js files are not downloaded and it is giving me file not found error.

Check the cast:
The github option is new in Bundler 1.1. If you don’t have this you’ll
need to pass in the full git path instead.
So try to use
gem 'jquery-datatables-rails', git: 'https://github.com/rweng/jquery-datatables-rails.git'

Difficult to say why your table is hidden without the view and associated javascript code.
Check if you call the dataTable() function on the correct table DOM element.
Also check for any fancy parameters in the call.
If that checks out, post the code for more help.

Related

Rails bootstrap gem monkeypatching method not working

I'm using the excellent twitter-bootstrap-rails gem. There is a helper within that gem (NavbarHelper) which is used to generate Bootstrap navbars with a Ruby helper. I want to monkey patch the gem such that the dropdown lists won't have carets.
So, I looked into the source and found the relevant method here. All I have to do is override it. I created a new file in config/initializers called navbar.rb with the following content:
NavbarHelper.module_eval do
def name_and_caret(name)
"HELLO WORLD"
end
end
Presumably, all of the dropdown titles then should be rendered as "HELLO WORLD" in my app (as referenced by the gem source). However, this is not occurring, and the gem does not appear to be monkeypatched at all.
I tried placing puts NavbarHelper.methods - Object.methods in the initializers file, and there were no results, which makes me think that Rails is not loading the gem correctly before the initializers. I have also checked and verified that the gem is not using autoload for its helpers.
Edit
What may be complicating this is the fact that my Gemfile includes the gem in the following manner:
gem 'twitter-bootstrap-rails', git: 'git://github.com/seyhunak/twitter-bootstrap-rails.git', branch: 'bootstrap3'
I'm not sure if this specific versioning means the monkeypatching doesn't work.
Edit #2
It seems there is only one version of the gem on my system, so I don't think that's the issue. Also, I have tried placing require 'twitter-bootstrap-rails at the top of the initializers file, with no results.
The problem is that you patch the method on this module but the module already got included at this point. Try to define this in your application_helper.rb
def name_and_caret(name)
super("blub #{name}")
end

No route matches POST when updating rails-api gem

When I add this to my gem file ( rails 4.0.1 )
gem 'rails-api', git: 'https://github.com/rails-api/rails-api.git', branch: 'master'
My routes seem to break (although rake routes is the same before/after)
I get this after I attempt to update a simple scaffold model
No route matches [POST] "/surveys/1" when I update a record
by commenting out this gem it works again - any ideas what I did wrong?
thanks!
PS: Adding this to gem file so I can use strong parameters to follow railscasts#196 in rails 4
Adding this to gem file so I can use strong parameters to follow
railscasts#196 in rails 4
Perhaps your app is having a problem with what you're using this gem for. I don't know if you've just upgraded to Rails 4, but the latest version uses Strong Params by default
The Railscast seems to be involved with loading nested forms. We do this all the time without the rails-api gem - can you let us know what you're trying to use this gem for specifically?

Trying to use coffeescript in a rails engine

I'm trying to use some coffee script in an engine but as soon as i name a file with:
*.js.coffee or *.coffee
an error is triggered and i can't load the page:
ExecJS::RuntimeError at /mylocation
SyntaxError: unexpected IDENTIFIER
The page won't load. My coffeescript is working in another app (Actually i'm trying to extract the logic from the main app to an engine). When i try using it in the engine it failed if it's a .coffee file.
I have in gemfile of the core app:
gem 'coffee-rails'
In the engine gemspec:
s.add_dependency 'coffee-rails'
If i rename the file to *.js the page loads but of course i see the syntax error in the js console.
Any idea where i should look or what should i do to use coffeescript in my engine ?
"Unexpected identifier" means that you have a variable you're trying to reference that hasn't been declared. Possibly a function which is not within the coffescript callback?
Make sure you pass all the variables you're trying to use.
I find my stupid error, the file i was playing with was and old js file and when i converted it to coffee i forgot to change the comments lines ( // to # )...

Looking for an example for a simplegeo API call in Ruby

After authenticating with simplegeo, I am simply trying to perform this:
SimpleGeo::Client.get_context(37.772445,-122.405913)
Turn the result into #variable and display the #variable on my "view" page.
Any suggestions? Thanks!
I'm working on a gem right now called SimpleGeo-Rails. It should make the whole process of working with the SimpleGeo Places a lot more rails-like. Just add the following to your Gemfile and then checkout the readme.
gem 'simplegeo-rails', :git => 'https://github.com/mgadda/simplegeo-rails.git'

attachment_fu and RMagick

After finally getting RMagick installed on my Mac I have set up attachment_fu according to the tutorial here: http://clarkware.com/cgi/blosxom/2007/02/24#FileUploadFu&gt when I try and upload a file via the upload form I get around 80 messages like these:
/Library/Ruby/Gems/1.8/gems/rmagick-2.13.1/lib/RMagick.rb:44: warning: already initialized constant PercentGeometry
/Library/Ruby/Gems/1.8/gems/rmagick-2.13.1/lib/RMagick.rb:45: warning: already initialized constant AspectGeometry
/Library/Ruby/Gems/1.8/gems/rmagick-2.13.1/lib/RMagick.rb:46: warning: already initialized constant LessGeometry
/Library/Ruby/Gems/1.8/gems/rmagick-2.13.1/lib/RMagick.rb:47: warning: already initialized constant GreaterGeometry
I did some searching and found that this problem can arise when you require RMagick twice in an application using different casing for the require statement: http://work.rowanhick.com/2007/12/19/require-rmagick-and-case-sensitivity/ I am not requiring it myself, but I was thinking maybe with the config.gem "rmagick" line in my environment.rb file rails might be requiring it.
After the form submits it gives me a validation error of: Content type is not included in the list
I have checked the source for attachement_fu and found the image/png in the list of content types so I don't believe that is the proper error message: http://github.com/technoweenie/attachment_fu/blob/master/lib/technoweenie/attachment_fu.rb
Does anyone have any ideas on how I can get this to work?
If, like us you're using a gem (such as gruff) which requires rmagick as above (and thus you can't really be correcting the case of the require statements), you can configure bundler to load rmagick using the matching case.
E.g. add the following to your Gemfile:
gem 'rmagick', '2.13.1', :require => 'RMagick'
That got us out of a real pickle today.
Thanks for the original post - we were lost until we read it!
Had a similar problem with Paperclip, solved by removing config.gem 'rmagick' line from environment.rb.
Update: The following only works on the Mac. My production server choked on this. Don't use it.
I came across this problem as well. In config/environment.rb I've got:
config.gem 'rmagick'
And it has to be lowercase, otherwise Rails thinks I don't have the required gem installed.
Attachment_fu has a file called rmagick_processor.rb which has the line:
require 'RMagick'
If you change this to lowercase, "require 'rmagick'", the RMagick error messages disappear.

Resources