Jump to content

The ultimate community for Ruby on Rails developers.


Photo

Using link_to in haml file


  • Please log in to reply
2 replies to this topic

#1 dailammoc

dailammoc

    Dispatcher

  • Members
  • 38 posts
  • Location/

Posted 30 March 2014 - 02:08 PM

I have a block code in haml file like this:

= form_tag url_for(action: :import), class: 'pull-right' do |f|
        = file_field_tag :csv, as: :file
        = submit_tag "CSV Upload", input_html: {class: "btn btn-white btn-sm"}

and i want to put it into link_to :

= link_to "CSV Upload", "#", class: "btn btn-white btn-sm"

(replace "#"). I still had no solution for this problem, please show me how?



#2 Jamie

Jamie

    Controller

  • Moderators
  • 140 posts
  • LocationNewcastle, UK

Posted 30 March 2014 - 06:08 PM

Why are you replacing the submit tag with an ahref?


Rails developer based in Newcastle, UK.


#3 dailammoc

dailammoc

    Dispatcher

  • Members
  • 38 posts
  • Location/

Posted 30 March 2014 - 06:47 PM

Why are you replacing the submit tag with an ahref?

because with href I can manage buttons easily:

 %p.pull-right
      = link_to "新規作成",  url_for(action: :new), class: "btn btn-white btn-sm"
      = link_to "CSV Export", url_for(action: :index, format: 'csv'), class: "btn btn-white btn-sm"
      = link_to "CSV Upload", "#", class: "btn btn-white btn-sm"

and I cannot do so if I use submit tag.






0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users