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