2

first: I promise I've read through every post regarding this topic, searched the whole web, but still don't know...

I have to models Trip (has_many) and Accomodation (belongs_to). Accomodations are nested in a Trip:

resources :trips do
    resources :routes, :accomodations
end

The controller looks like that:

def new
  @accomodation = Accomodation.new
end

def create
   @accomodation  = Accomodation.new(params[:accomodation])
   if @accomodation.save
     flash[:success] = "Accomodation created!"
     redirect_to new_trip_accomodation_path(@trip)
   else
     render 'pages/home'
  end
end

The form:

<%= form_for([@trip, @accomodation]) do |f| %>
    <%= render 'shared/error_messages', :object => f.object %>
    <div class="field">
           <%= f.label :title, "Titel" %>
           <%= f.text_field :title %>
    </div>
    <div class="field">
    <%= f.label :description, "Beschreibung" %>
    <%= f.text_field :description %>
    </div>

   <div class="actions">
       <%= f.submit "Create" %>
   </div> 
<% end %>

The form renders the correct html (as far as I can see):

<form accept-charset="UTF-8" action="/trips/51/accomodations" class="new_accomodation" id="new_accomodation" method="post">

Ok, so when I submit the form, nothing happens. When I look into the server log, I can see the get-request to render the new-Form. But no reaction on the submit... Is the form not submitting at all? Why? I have absolutely no idea.

What else did I try?

 <%= form_for([@trip, @accomodation], :url => { :action => :create }, :method => :post) do |f| %>

Nothing.

 <%= form_for([@trip, @accomodation], :url => { :action => :create }, :method => :post) do |f| %>

Nothing as well.

<%= form_for([@trip, @accomodation, @trip.accomodations.new]) do |f| %>

Forget it.

Can anybody help. Any clues where I could start diggin?

Thanks in advance!

2 Answers2

0

Are you sure that the line after

<form accept-charset="UTF-8" action="/trips/51/accomodations" class="new_accomodation" id="new_accomodation" method="post">

isn't

</form>

?

snowangel
  • 3,452
  • 3
  • 29
  • 72
0

If there is no server log for this request, that means the browser doesn't trigger the submit action. Do you have some javascript that could interfere with the submit action ? try removing all javascript includes in your headers and test again. Hope it helps.

EppO
  • 23
  • 1
  • 5