I'm a Rails newbie, and I have a RoR app that I'm working on, the app is supposed to allow invited guests to RSVP to a wedding.
I have allowed for fields to be dynamically added, in order to include additional guests (family of an invited guest). But when I add the dynamic field and add the names, only the last name is displayed in the index.
Is there anything specific I need to do to render all other names together in a field within the table?
This is my current controller thus far:
class GuestsController < ApplicationController
skip_before_filter :authenticate_user!, only: [:new, :create]
def index
@guests = Guest.all
end
def new
@guest = Guest.new
end
def create
@guest = Guest.all
@guest = Guest.create(guest_params)
if @guest.save
respond_to do |format|
format.html { redirect_to :back, notice: 'Thank you for replying' }
format.js
end
else
respond_to do |format|
format.html { render 'new' }
format.js
end
end
end
def destroy
@guest = Guest.find(params[:id])
@guest.destroy
redirect_to guests_path
end
private
def guest_params
params.require(:guest).permit(:status, :name, :message)
end
end
Rsvpmodel thathas_manyGuests(if something like this were the case, there are gems and tools for adding nested objects to the Rsvp form)? The more specific and detailed your question and supporting info is, the better responses you'll get!