1

I am trying to create a new record when a user pushes a button. The page seems to be refreshing but no records are being created

%tbody
- page_list.each do |page|
  %tr
    %td.text-center=image_tag "https://graph.facebook.com/#{page['id']}/picture?width=40&height=40"
    %td= link_to page['name'], "http://www.facebook.com/#{page['id']}"
    %td= page['category']
    %td
      %span.webicon.facebook
    %td
      =link_to 'Import Page', pages_path(:page => { name: page['name'], page_id: page['page_id'] }, :controller => :pages), :class => 'button default tiny'
      =link_to 'View Page', "http://www.facebook.com/#{page['id']}", class: 'button default tiny'
Boss Nass
  • 3,384
  • 9
  • 48
  • 90

1 Answers1

2

Change your link_to to:

= link_to 'Import Page', pages_path(:page => { name: page['name'], page_id: page['page_id'] }), :class => 'button default tiny', :method => :post

And it's going to work. Links default to use GETbut what you need is a POST here.

MaurĂ­cio Linhares
  • 39,901
  • 14
  • 121
  • 158