RJS Handler missing - ruby-on-rails-3

I got a missing template error when I tried to achieve a task using RJS.
All I want is to execute an RJS file on ajax call. But I am getting the
following error.
ActionView::MissingTemplate (Missing template line_items/create,
application/create with {:handlers=>[:erb, :builder, :coffee],
:formats=>[:js, :html], :locale=>[:en, :en]}. Searched in:
* "<MY APP PATH>/app/views"
):
app/controllers/line_items_controller.rb:46:in `create'
But the create.js.rjs is present in the folder /views/line_items. You
can see the handlers miss .rjs extension. I think thats causing the
error.
If I change .rjs to .erb, it works and the content is executed as
javascript and thus I need to modify the RJS functions to Javascript to
return the contents of AJAX call.
Could you please explain how I can attain this using RJS? Please help.
Following is the versions of tools I use.
Ruby version 1.9.2 (i686-linux)
RubyGems version 1.8.10
Rack version 1.3
Rails version 3.1.0
JavaScript Runtime Node.js (V8)
Active Record version 3.1.0
Action Pack version 3.1.0
Active Resource version 3.1.0
Action Mailer version 3.1.0
Active Support version 3.1.0
Thanks in advance.

in order to use RJS with Rails 3.1 you have to use the prototype-rails gem

Make sure prototype-rails gem is in bundler's production group. If you put it in the assets group it will not register the RJS template handler.

Related

Quickbooks & Rails 5, can't create an invoice

Things were working fine until I started the upgrade from Rails 4.2 to 5.0
Using qbo_api gem (1.8.1) which also now needs the simple_oauth (0.3.1) as well as the oauth (0.5.4) gem. (The faraday gem (0.14.0) is loaded as another dependency.)
I can successfully do get requests for invoice, customer, etc., so the keys and initialization of the qbo_api object are all working for qbo_api.get() but when I try to create an invoice with qbo_api.create(:invoice, payload: ...), I get the error:
Operation Could not find resource for relative : /v3/company/123145710499109/invoice of full path: https://sandbox.qbo.intuit.com/qbo50/v3/company/123145710499109/invoice is not supported.
The same qbo_api object is working for get, I see nothing obviously wrong with the URL, and it is unreleated to the JSON payload. I'm not sure where to look to debug this problem.
BTW, clicking on the URL above seems to go to QB just fine, returning a validation error as you would expect.
This turns out to be a problem in the 1.8.0 and 1.8.1 versions of the qbo_api gem. Minimul has released version 1.8.2 which fixes this problem.
Kudos to Minimul for a quick response to this.
check your realmId. Most probably realmId is not match to your connected intuit app. This is why its tells that Operation Could not find resource for relative.

Devise_invitable in rails 4?

I am trying to use devise_invitable(0.1.3) in my application and my application already uses devise(3.1.0). I specified the devise_invitable in my gem file and run bundle install it installed successfully but when i run any command it gives the following error:
Error:
uninitialized constant DeviseMailer (NameError)
Can anyone tell what i am doing wrong?
Any help would be appreciated.
Thank You
Per the devise_invitable README, you need to be using the version straight from github if you are on Rails 4:
gem 'devise_invitable', :github => 'scambra/devise_invitable'

Rails with Jader gets 'failed to require "fs"' error

I am trying to use client side Jade templates that are precompiled by Ruby on Rails and available through JST.
I added the jader gem
gem "jader", "~> 0.0.8"
In configuration/initializers I created an initializer called jader.rb that contains:
Jader.configure do |config|
config.views_path = Rails.root.join('app','assets','javascripts','views')
config.mixins_path = Rails.root.join('app','assets','javascripts','mixins')
end
In app/assets/javascripts/views I added an index.js.jst.jade file
Hello World!
Lastly in my javascript file I have:
$('#app-content').append(JST["views/index"]());
When I run Rails and browse to the page triggering the code I am getting the following error:
failed to require "fs"
(in /my-project/app/assets/javascripts/views/index.js.jst.jade)
I understand that the problem is that jade is a node.js project and the require function is having a problem. How do I fix the require error?
If you are looking at using Jade templates only on the client side (with Rails asset pipeline), I recommend https://github.com/inossidabile/jade
It's likely there is an error in your index.jade template.
From the jade rails-fix pull request here, ExecJS used by rails does not support require("fs") and will throw 'failed to require "fs" even if it's a template error. Hopefully this should point you in the right direction.
To debug, you can replace the content of index.jade template with with a 1-liner jade placeholder to see if it renders well. Alternatively, try it out rendering the index.jade template with a nodejs server if possible to be sure the template renders without any whinning.

Cannon create vendor plugin

I am using Rails 3.2.2
In my project root command: rails generate plugin somename gives me error:
Could not find generator plugin
I can create only gem plugin.
Could somebody give me any advice?
The plugin generator has been removed as of release 3.2 (see here). Try this: rails plugin new my_plugin
If you need to digest how plugins created internally:
https://github.com/rails/rails/blob/master/railties/lib/rails/generators/rails/plugin_new/plugin_new_generator.rb line 170 initialize

ruby rest_client exception

I try to use gem rest client to access some simple REST service, I have installed the rest-client following these instructions, but when try to use the library, I get the following error no such file to load -- rest_client.
It seems that the library is not recognized.
Did anyone have similar problems with this library?
Make sure you add it to your Gemfile, bundle install, restart server, and if required, require 'rest_client' or whatever the file name is.