jquery_datepicker not working with Rails 4 - ruby-on-rails

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

Related

Simple nested form for field

I don`t understand this from rails 4:
<td colspan="12" id="compatibility_activities-add" >
<%= job.link_to_add t('shared.add'), :activities,:class => "right small button radius success", :data => { :target => "#activities#{job.object.person_type}_#{job.index}" } %>
</td>
where does the "link_to_add" comes from? there is no references inside the project and cant find anything on the net, there is another "link_to_remove"
this is on a list that creates new rows or deletes them dynamicaly
My second question is, does rails 4 have the way, like laters versions to do rails routes | grep some_route ??
The helper methods you mentioned seem to be provided by the gem Nested Form or some fork of it.
Check your Gemfile for the specific gem name and you can get the official documentation on GitHub or on its website.
In rails 4, you could try using rake routes or bundle exec rake routes to get the list of the routes.

link_to_function in rails 3.1 with blocks throws wrong number of arguments error

I recently started working with rails 3. I'm trying to add a multi-modal form into my application. I'm following the steps mentioned at Handle multiple models in one form
When I try to add a link via following helper function, I get
wrong number of arguments (1 for 2)
Code block below.
def add_task_link(name)
link_to_function name do |page|
page.insert_html :bottom, :tasks, :partial => 'task' , :object => Task.new
end
en
Googling for solution didn't take me anywhere.
Thank you.
You should find another tutorial, RJS and prototype are deprecated in rails 3, they've been replaced with jQuery.
If you really insist on going forward, you can bring RJS and prototype back by adding the following to your Gemfile:
gem 'prototype-rails'
This will bring back the correct version of link_to_function.

undefined method `html_safe' for #<String:0x1042222c0> using recaptcha

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.

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.

active_scaffold routing error

If you haven't seen my question yesterday, this is my second rails app. The first went nice and smooth, but this one keeps giving me one random error after another. I installed active_scaffold for this app as well as the last app (the first error, instead of using script/install plugin git://active_scaffold repository, I did script/install plugin http://active_scaffold repository.) I didn't want to spell out basic CRUD on minor models. After the install problems, (before I found the http solution from a windows user when I'm on Linux) I thought I'd try out Hobo. Well, Hobo updated actionmailer, actionpack, activerecord, activeresource, and installed rack. Rails isn't even using the updated versions. But as you can see at the bottom of the trace it's using rack. I have a feeling it has something to do with my futzing around with installing Hobo which I uninstalled. Thanks in advance.
[Edit]
I had asked the question over at the
ActiveScaffold Group
the answer (if you don't want to follow the link) was that this line needed to be added to routes:
map.resources :modelName, :active_scaffold => true
It doesn't entirely answer my question, since the documentation said nothing about changing routes. But, it works.
[/Edit]
ActionController::RoutingError in Departments#index
Showing vendor/plugins/active_scaffold/frontends/default/views/_list_header.html.erb where line #8 raised:
No route matches {:_method=>:get, :action=>"show_search", :controller=>"departments"}
Extracted source (around line #8):
5: <% next if controller.respond_to? link.security_method and !controller.send(link.security_method) -%>
6: <% next if link.action == 'new' && params[:nested].nil? && active_scaffold_config.list.always_show_create %>
7: <% next if link.action == 'show_search' && active_scaffold_config.list.always_show_search %>
8: <%= render_action_link(link, new_params) -%>
9: <% end -%>
10:
11: <%= loading_indicator_tag(:action => :table) %>
Trace of template inclusion: vendor/plugins/active_scaffold/frontends/default/views/list.html.erb
Full Trace It was taking forever to format it. I'm still not fully conversant in SO's formatting (sometimes the server is down. reboots are reinstalls. it's a play server)
Add this to routes:
map.resources :modelName, :active_scaffold => true
And, contrary to my edit, it is in the documentation. It's in the wiki at Github. My second question at SO, and I could have found the answer by RTFM'ing. <sigh>
For Rails 4+ at least, your entry in config/routes.rb should look like:
resources :models do # my model name in plural
as_routes
# for action links of type member, add the following
# see also [note, via the action-link API, you can change the HTTP verb. Adjust this route accordingly.
# https://github.com/activescaffold/active_scaffold/wiki/Adding-custom-actions
# get :my_custom_action, :on => :member
end
Note, getting the right version of the Gem requires the following config in your Gemfile:
gem 'active_scaffold', github: 'activescaffold/active_scaffold', :branch => "3-4-stable"
If you get an error that "as_routes" isn't found; that'd be the problem.
THIS IS RAILS 4 ONLY
For Rails 5.x you can set route as follow:
resources :model, concerns: :active_scaffold

Resources