Try hobo_create_for :imovel

On Dec 7, 12:54 am, Daniel M <[email protected]> wrote:
> I also have these new_for and edit_for set:
>
>   def new_for_builinding
>     hobo_new_for :builinding do
>       this.attributes = params[:address] || {}
>       hobo_ajax_response if request.xhr?
>     end
>   end
>
>  def edit_for_builing
>     hobo_edit_for :builinding do
>       this.attributes = params[:address] || {}
>       hobo_ajax_response if request.xhr?
>     end
>   end
>
> But with this:
>
>  def create_for_imovel
>     �...@cont= Address.new(params[:address])
>     if @cont.save
>       flash[:notice] = "Address saved sucessfully"
>       respond_to do |format|
>         format.html { redirect_to building_path(@cont.building.id) if
> valid? }
>         format.js
>       end
>     else
>           hobo_create
>     end
>   end
>
> The result its the same, it fails :(
>
> On Dec 7, 1:43 am, kevinpfromnm <[email protected]> wrote:
>
> > what happens if you drop the block to hobo_create and just leave it
> > vanilla hobo?
>
> > On Dec 6, 4:43 pm, Daniel M <[email protected]> wrote:
>
> > > Sorry, translation problems...here its the actually correct one
>
> > > def create_for_imovel
> > >     �...@cont= Address.new(params[:address])
> > >     if @cont.save
> > >       flash[:notice] = "Address saved sucessfully"
> > >       respond_to do |format|
> > >         format.html { redirect_to building_path(@cont.building.id) if
> > > valid? }
> > >         format.js
> > >       end
> > >     else
> > >           hobo_create do
> > >                         this.attributes = params[:address] || {}
> > >                         hobo_ajax_response if request.xhr?
> > >                 end
> > >     end
> > >   end
>
> > > Any ideas about what its missing?
> > > Thank you.
>
> > > On Dec 6, 11:40 pm, Daniel M <[email protected]> wrote:
>
> > > > My controller has the following controller (extend because ajax
> > > > porpuses)
>
> > > > def create_for_imovel
> > > >     �...@cont= Address.new(params[:address])
> > > >     if @cont.save
> > > >       flash[:notice] = "Address saved sucessfully"
> > > >       respond_to do |format|
> > > >         format.html { redirect_to building_path(@cont.building.id) if
> > > > valid? }
> > > >         format.js
> > > >       end
> > > >     else
>
> > > >           hobo_create do
> > > >                         this.attributes = params[:morada] || {}
> > > >                         hobo_ajax_response if request.xhr?
> > > >                 end
> > > >     end
> > > >   end
>
> > > > Thankz
>
> > > > On Dec 6, 11:29 pm, Daniel M <[email protected]> wrote:
>
> > > > > Hi all.
>
> > > > > I have the following (simplified) model:
>
> > > > > class Address < ActiveRecord::Base
> > > > >   hobo_model # Don't put anything above this
> > > > >   fields do
> > > > >           street :string
> > > > >           nr :string
> > > > >           floor :integer
> > > > >           postal_code :integer
> > > > >           latitude :string
> > > > >           longitude :string
> > > > >     timestamps
> > > > >   end
>
> > > > >   belongs_to :person
> > > > >   belongs_to :building
> > > > >   belongs_to :apartment
>
> > > > >  belongs_to: city
> > > > >  belongs_to: country
>
> > > > >  validates_presence_of :city
>
> > > > > end
>
> > > > > When i create one address for a building, everything goes, ok, the new
> > > > > form its rendered (ok) with the title:
>
> > > > > New Address
>
> > > > > For: Building One
>
> > > > > But if i create the building without a city, validation fails and it's
> > > > > rendered :
>
> > > > > New Address
>
> > > > > For: (Not Available)
>
> > > > > To proceed please correct the following:
>
> > > > > City can't be blank
>
> > > > > That means that some how the belongs_to its lost and i dont know how
> > > > > to recover the belongs_to context...
>
> > > > > Any ideas?
> > > > > Thanks in advance.
>
> > > > > Ps: hobo version - 0.8.5

-- 
You received this message because you are subscribed to the Google Groups "Hobo 
Users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/hobousers?hl=en.

Reply via email to