开发者

Rails 3 - Can't figure out Create/Update form clause

开发者 https://www.devze.com 2023-03-20 08:57 出处:网络
Can someone tell me what I\'m doing wrong here? I\'m using the same page to do my Create and Update form have this code right at the top of my page:

Can someone tell me what I'm doing wrong here? I'm using the same page to do my Create and Update form have this code right at the top of my page:

This works:

<% if @media.blank? %>
  &开发者_如何学Pythonlt;%= form_for(:media, :url => {:action => 'create'}) do |f| %> 
<% end %>

This doesn't:

<% if @media.blank? %>
  <%= form_for(:media, :url => {:action => 'create'}) do |f| %> 
<% else %>
  <%= form_for(:media, :url => {:action => 'update', :id => @media.id}) do |f| %>
<% end %>

The latter gives me this result: syntax error, unexpected keyword_else, expecting keyword_end'); else

Should I be doing my create & update in a different way?

Thanks.


<% if @media.blank? %>
  <%= form_for(:media, :url => {:action => 'create'}) do |f| %>
  <% end %> 
<% else %>
  <%= form_for(:media, :url => {:action => 'update', :id => @media.id}) do |f| %>
  <% end %>
<% end %>
0

精彩评论

暂无评论...
验证码 换一张
取 消