adding a class to a link_to is breaking the link

<%= link_to “Add to your favorites list”,{:controller => ‘favourite_companies’, :action =>’create’}, :company_id=>”#{@company.id}”, :company_name=>”#{@company.company_name}”, :class=>”ui-button-text button_text”} %> try this <%= link_to “Add to your favorites list”, :controller => ‘favourite_companies’, :action =>’create’, :company_id=>”#{@company.id}”, :company_name=>”#{@company.company_name}”, { :class=>”ui-button-text button_text” } %> Since the :class should be in :html_options (refering to API) link_to(body, url, html_options = {})

rails link_to :remote

You can bind to ajax calls like this: <%= link_to my_path, method: :delete, confirm: ‘Delete?’, class: ‘link-delete’, ‘data-message’ => ‘Are you sure?’, ‘data-severity’ => ‘danger’, :remote => true do %> <i class=”icon-trash”></i> <% end %> $(‘.link-delete’).bind(‘ajax:beforeSend’, function() { $(‘#mySpinner’).show(); }); $(‘.link-delete’).bind(‘ajax:complete’, function() { $(‘#mySpinner’).hide(); });

How do I defined a variable link_to to an external URL

It sounds like you are storing URLs without the http:// so they are being interpreted as relative URLs. You just need to do something like this: link_to micropost.website, “http://#{micropost.website}” or maybe add a full_url method to that model that adds it if it’s missing. By the way, you can’t use @micropost in that partial because … Read more

file download link in rails

Rails 4: in routes: get “home/download_pdf” in controller (already have pdf): def download_pdf send_file( “#{Rails.root}/public/your_file.pdf”, filename: “your_custom_file_name.pdf”, type: “application/pdf” ) end in controller (need to generate pdf): require “prawn” class ClientsController < ApplicationController def download_pdf client = Client.find(params[:id]) send_data generate_pdf(client), filename: “#{client.name}.pdf”, type: “application/pdf” end private def generate_pdf(client) Prawn::Document.new do text client.name, align: :center text … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)