Closed fabdurso closed 6 years ago
You don't need to use send for the options, you only use that to call the correct method. The rest aren't methods.
<%= send "#{user.settings(:calendar).type}", number_of_weeks: user.settings(:calendar).weeks, events: calendar_events do |date, events| %>
Couldn't be easier... Thanks @excid3 !
I'm using rails-settings to manage user settings like:
calendar
,week_calendar
,month_calendar
Now, let's say that the user calendar_type is
week_calendar
and I want to set thenumber_of_weeks
<%= send "#{user.settings(:calendar).type}", number_of_weeks: 1, events: calendar_events do |date, events| %>
will work, but
<%= send "#{user.settings(:calendar).type}", number_of_weeks: send "#{user.settings(:calendar).weeks}", events: calendar_events do |date, events| %>
won't work, nor
<%= send "#{user.settings(:calendar).type}", "number_of_weeks: "#{user.settings(:calendar).weeks}", events: calendar_events do |date, events| %>
Which would be the right formatting?