Closed cjwightman closed 7 years ago
Would you mind pushing up your code and sending over the link?
Ok, got it to work. Two things...
Remove the @plant.season = Season.all.sample
bit from the plant create
action since you're handling season assignment in the form.
Make a small tweak to the season drop down. I noticed that it was passing season: 1
and not season_id: 1
through params. We need the latter since that's what you specified in your strong params method. So the updated drop down would look like this...
<%= collection_select(:plant, :season_id, Season.all, :id, :name) %>
Let me know if that works for you!
Wow! So jealous of your crazy skills. Thank you so much you wizard of ruby.
:+1:
Plants belong to seasons. My form to create a new plant does not come from within a season so a season must be defined within the form. I currently have a drop-down menu to select the season. Oddly, regardless of what season is selected, when the new plant is created it is assigned a seemingly random season. I have a feeling the issue could involve my create method in the plant controller.
def create
@season = Season.find(params[:season_id])
end
I'm guessing it has something to do with the "Season.all.sample" but it breaks if I remove that and I don't know what an alternative would be.