Hello,
I am confronted with a very strange problem which I can not solve… and
God I tried a lot, lost almost a whole day, but couldn’t find an answer:
The idea is to have a form both in admin and in dir, in admin there will
be some more fields that is why I have twice a form. In admin the form
appears, in dir the form does not appear instead
“þÿ
New company” why is it that the code is not interpreted and how can I
solve the problem ?
Thank you very much,
The code here below is fairly simple as you can see…
in two controllers (resp. Dir and Admin)
def index
list
render :action => ‘list’
end
def new
@company = Company.new
end
def create
@company = Company.new(params[:company])
if @company.save
flash[:notice] = ‘Company was successfully created.’
redirect_to :action => ‘list’
else
render :action => ‘new’
end
end
in both views (resp. Dir and Admin)
New company
<%= start_form_tag :action => ‘create’ %>
<%= render :partial => ‘form’ %>
<%= submit_tag “Create” %>
<%= end_form_tag %>
<%= link_to ‘Back’, :action => ‘list’ %>
in both _forms (resp. Dir and admin)
<%= error_messages_for ‘company’ %>
Name <%= text_field 'company', 'name' %>
Adline <%= text_field 'company', 'adline' %>
Adline2 <%= text_field 'company', 'adline2' %>
Postcode <%= text_field 'company', 'postcode' %>
City <%= text_field 'company', 'city' %>
State <%= text_field 'company', 'state' %>
Country <%= text_field 'company', 'country' %>
The model Company :
class Company < ActiveRecord::Base
validates_presence_of :name, :email, :url
validates_uniqueness_of :email, :url
validates_format_of :email,
:with => %r{.@.},
:message => “not a valid email”
def self.find_companies
find(:all, :order => “name”)
end
end