Questions tagged [link-to-function]

link_to_function is a Rails 3 helper that allows to create a link whose onclick handler triggers the passed JavaScript. Deprecated in Rails 4.

The function works in one major Rails release and removed from another. That's why use of this is puzzling a lot of people.

18 questions
21
votes
3 answers

Status of Rails' link_to_function deprecation?

What is the status of the link_to_function Javascript helper in Rails? I read, including in this stackoverflow question, that it was deprecated in Rails 3.0, then undeprecated, then deprecated again in 3.2.4. Is it something I can depend on and…
6
votes
1 answer

How to replace link_to_function for rails 4.1

I am in the middle of creating my first real Rails app, and I'm learning on the go. I have a situation where I need to create nested attributes on one form, and so have been looking at the railscast episodes relevant to that (196 and 197). In the…
Michael Cruz
  • 864
  • 6
  • 13
5
votes
2 answers

Attaching onClick event to Rails's link_to_function

How do I attach an onclick event to a link_to_function such that clicking on the event refreshes an element on the page (using partials)? When the user clicks the generated link, I'd like to refresh the partial containing the code so that i gets…
sutee
  • 12,568
  • 13
  • 49
  • 61
4
votes
3 answers

Rails: Specifing params without value to link_to

Supposing the route map.resources :articles how do you get this /articles?most_popular using link_to method? tried the following: link_to articles_path(:most_popular) # exception link_to articles_path(:most_popular => nil) # /articles link_to…
knoopx
  • 17,089
  • 7
  • 36
  • 41
1
vote
1 answer

How to display current username as a Link in RUBY?

<%= link_to ' ', user_path(current_user) %> How do I make it so <% current user %> displays the current user as a link. Because in ruby whatever goes inside Link to is written as a string and not displayed as Ruby's answer.
Ramish Mian
  • 137
  • 1
  • 2
  • 13
1
vote
1 answer

Rails. Extend link_to helper

How to extend Rails link_to helper to add a specific class and not to break link_to standard functionality. I want to have my custom helper like this: module MyModule module MyHelper def my_cool_link_to(body, url_options, html_options) …
Max Ivak
  • 1,529
  • 17
  • 39
0
votes
1 answer

How to handle link_to_function in rails3

This is my code <%= link_to_function ("Add another url", :id=> "add_another_url_link_id") do |page| page.insert_html :bottom ,:add_another_url, :partial =>'add_another_url', :locals => {:object =>Url.new, :url => section} …
vinothini
  • 2,606
  • 4
  • 27
  • 42
0
votes
2 answers

replace input button with jquery

I'm trying to replace a Submit button in a form with a javascript function. I'm able to insert the following link_to_function for submitting the form: <%= link_to_function 'Create', "$('form').submit()" %> Now, I want to replace the default form…
user700304
  • 45
  • 4
0
votes
1 answer

How to use "link_to" in an Admin section correctly in Rails

So I have an app which has an admin section. The admin section has a challenges controller with an index method and a view index. I have also a challenges controller seperate from the admin folder. This controller has the whole CRUD. Every…
Micromegas
  • 1,499
  • 2
  • 20
  • 49
0
votes
1 answer

Nested form and link_to_function

I've got a nested form like this : <% form_for setup_training(@training), :url => admin_trainings_path, :html => { :class => :form } do |f| -%> <% f.fields_for :days do |days_form|…
0
votes
1 answer

Rails 4 link_to No route matches

I get the error No route matches {:action=>"index", :controller=>"search"} When using link_to "Next Page", {:controller => 'search', :action => 'index'} My routes.rb contains resources :search, only: [:index] The action works fine when I use…
vinoy
  • 1
  • 3
0
votes
1 answer

How to solve duplicate records in my rails app

We use Formtastic and built add_fields / remove_fields for one to many association models based on this railscasts. Now we are encountering a duplicate entries problem. Say, after we create a new project, and then edit this project with 3 tasks…
0
votes
1 answer

rails find_by: get the first item by adding the reference key as parameter

I'm new to Rails and I'm building a quizz application. I have a has_many and belongs_to association set up between two models: Level and Question. #models/level.rb class Level < ActiveRecord::Base has_many…
shann
  • 21
  • 2
0
votes
1 answer

Rails 4 nested attributes link_to_function

i am making a simple app that should remove fields dynamically using rails 4 , i am doing that basically bu following rails cast tutorial , but its in rails 3 , i manged to solve most of the problems thanks God but i am stuck in this one ,the…
0
votes
2 answers

rails link_to_function in a do

I have a link_to_function working correctly in my rails app, but I've tried wrapping it around some ruby code using "do", and it's not executing the code it's wrapped around:
  • <%= link_to_function…
  • scientiffic
    • 9,045
    • 18
    • 76
    • 149
    1
    2