undefined method `html_safe' for #<String:0x1042222c0> using recaptcha - ruby-on-rails

I'm getting this error on the line where I call recaptcha_tags
<%= recaptcha_tags( :public_key => 'XXXXXXYYYYYYYZZZ-ZXYXXZYZ' , :display=>{:theme=>"white" }) %>
I'm working with rails 2.3.10
how can I solve this error?
many thanks.

In Rails 2.3.x, html_safe is defined as a String class method in:
activesupport/lib/active_support/core_ext/string/output_safety.rb
Make sure that you have the proper active_support version (one matching your rails version).

Well i did what's specified here https://github.com/ambethia/recaptcha/issues/30 and worked out perfectly for me
Changing client_helper.rb line 39 to:
return (html.respond_to?(:html_safe) && html.html_safe) || html
fixes the issue.

Related

jquery_datepicker not working with Rails 4

See the following repo for example project: https://github.com/aarona/date_picker
At first I thought the problem was caused by the model being tableless but when associating it with the database through a migration I still get an error:
wrong number of arguments (1 for 0)
on this line:
<%= f.datepicker :start_date, :class => 'short' %>
I get an error about delete method not found if the model is tableless.
Turns out that the gem jquery_datepicker is incompatible with Rails 4. Time to use a different gem/control if I want to upgrade.
A solution is available for Rails 4+. You can find this solution here:
https://stackoverflow.com/a/43289610/43792

Rails 4.2 will_paginate error

Trying to upgrade to Rails 4.2 from 4.1.8 and I'm getting a "wrong number of arguments (2 for 0..1)" for this line:
<%= will_paginate(#search) %>
Works perfectly find in Rails 4.1.8. #search is a custom object which defines the methods will_paginate needs (total_pages, etc).
The method signature for will_paginate is:
def will_paginate(collection = nil, options = {}) #:nodoc:
And I verified the proper method is being called by using:
<%= self.method(:will_paginate).source_location %>
Which outputted:
["/Users/home/.rbenv/versions/2.1.0/lib/ruby/gems/2.1.0/gems/will_paginate-3.0.7/lib/will_paginate/view_helpers/action_view.rb", 26]
Kind of stumped, and surprised that nobody else has encountered this issue.
Turns out the bartt-ssl_requirement gem overrides :url_for in a way that is not compatible with Rails 4.2. Removing that gem resolved the issue.

will paginate in rails 3

I'm upgrading my rails 2.3.8 app to rails 3.0.1 while using will_paginate in one module
for example:
<%= will_paginate #sample , :renderer => 'RemoteLinkRenderer' , :remote => {:loading => 'loadingPanel.show()',:complete => 'loadingPanel.hide()' } %>
This code isn't working.
Any ideas are greatly appreciated
I don't want to look rude but "This code doesn't working" isn't enough to be helped. You should provide more informations about your problem :)
You are not simply using will paginate. Apparently, you are also using this patch, and it is not working with Rails 3.
You should edit the question and update it's title to somthing like "remote pagination via Ajax with will_paginate and rails 3".
There is one html5-based solution described here
To convert this solution into non-html5 you may maybe do something like this(*):
$$('.pagination a').each(function(e){
var link=e.getAttribute('href');
e.setAttribute(
'onclick',
'new Ajax.Request(\'' + link + '\', {asynchronous:true, evalScripts:true})');
e.writeAttribute('href',null);
}
* has to be trimmed if there are multiple paginations...

RoR rendering images inline rails 2.3.8

I'm trying to render an image inline in an email, and my rails app is version 2.3.8.
Can someone provide me with an example of how to do this? Here's what I got so far, but I keep getting errors.
Here's my method:
def notice(contact)
subject 'notice'
recipients contact.email
from 'something.com'
sent_on Time.now
attachments.inline['paypal_seal.gif'] = File.read('/images/paypal_seal.gif')
body :contact => contact
end
And in the view:
<%= image_tag attachments['paypal_seal.gif'].url %>
This is the error I get:
undefined local variable or method `attachments' for #<ContractorNotifier:0x61413c8>
Thank you
What you are trying to do is the 'Rails 3' way of handling attachments. If you are starting out, I highly recommend upgrading to Rails 3. Otherwise, try an older 2.3 guide like:
http://blog.thoughtobject.com/2007/05/26/5/

RoutingError on Ruby Rails?

Hey everyone, thanks for reading this.
Ihave the next issue: When I call my "New" template (generated by scaffold) I got the next error:
<h1>ActionController::RoutingError in Flujos_de_trabajo#new</h1>
Showing app/views/flujos_de_trabajo/new.html.erb where line #3 raised:
flujos_de_trabajo_url failed to generate from {:controller=>"flujos_de_trabajo", :action=>"show"} - you may have ambiguous routes, or you may need to supply additional parameters for this route. content_url has the following required parameters: ["flujos_de_trabajo", :id] - are they all satisfied?
Extracted source (around line #3):
1: <h1>New flujo_de_trabajo</h1><br/>
2: <br/>
3: <% form_for(#flujo_de_trabajo) do |f| %><br/>
4: <%= f.error_messages %><br/>
5: <br/>
6: <p><br/>
I have overlooked everything, and I don't know what the problem is. The code in the view and in the controller is the same as the generated. In fact, i deleted it, generated it againg, and nothing, the same problem. Can you help me?
Did you do this.
script/generate scaffold FlujosDeTrabajo
rake db:migrate
http://localhost:3000/flujos_de_trabajos/new
it is working for me
Rails is really bad for languages that aren't English. It's failing here because it thinks that "flujo_de_trabajo" is the singular version of "flujo_de_trabajo". You're going to have to set up some inflections telling Rails the correct singular version of this. Look at the examples in config/initializers/inflectors.rb.

Resources