You should replace resources :trials
with resources :trial_subscriptions
Simple_Form is looking for a path but can't find it undefined method trial_subscriptions_path
-
19-06-2023 - |
Question
Here is my views/trials/new.html.erb
<%= simple_form_for @subscription do |f| %>
<%= f.input :manual_expiry_date %>
<%= f.association :user %>
<%= f.button :submit %>
<% end %>
I have
resources :trials
in my trials_controller.rb
def new
@subscription = TrialSubscription.new()
end
def create
@subscription = TrialSubscription.new(params[:subscription])
if @subscription.save
redirect_to root_url, notice: "Thank you for adding a host!"
else
flash["not working yet"]
end
end
Its yelling undefined method trial_subscriptions_path
TrialSubscription is a model class that inherits from Subscription model. A user has many subscriptions.
I need to build a form so when a user puts in the email, the user gets created and that its associated trial subscriptions get created as well.
I am iterating through the form. I want the trial_subscription created before working on its (belong_to) association or hooking up the user part.
Solution
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow