Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

wrong number of arguments (given 0, expected 1) rails 6.1.1

I check current page with rails 5.1.2 and no problem, but rails 6.1.1 error wrong number of arguments (given 0, expected 1)

<% if current_page?(controller: 'categories', action: 'new')%>
    <%= link_to "&larr;".html_safe  + @shop.name, shops_path, class: "btn btn-sm btn-primary" %>
<%else%>
    <%= link_to "&larr; Volver".html_safe, new_shop_category_path, class: "btn btn-sm btn-primary" %>
<%end%>

My first solution is

<% if controller_name == 'categories' && action_name == 'new'%>

but I would like to know the problem

any idea? Thanks!

like image 547
Javito Avatar asked Dec 06 '25 08:12

Javito


1 Answers

Pass a hash instead of keyword arguments:

current_page?({controller: 'categories', action: 'new'})
like image 198
milkfarm Avatar answered Dec 12 '25 11:12

milkfarm



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!