BTW. Just to clarify, the dc_locs_controller.rb looks that way because
I don't understand exactly how to apply a scope or custom sql to pull
into an array.
That's probably obvious.

Thanks,
M

On Jun 7, 7:59 am, Michael M <[email protected]> wrote:
> Hi all, recovering Perl addict here to ask a hopefully easy question.
>
> First off, as someone completely new to Rails and subsequently Hobo, I
> want to thank you for a very interesting and usable system for rapidly
> creating a website!
> Accolades aside, some of the magic that hides the inner workings,
> hides them a bit too well for someone trying to learn, hence my
> question.
>
> I'm running Ruby 1.9.1, Rails 3.0.7, and, I think, the latest version
> of Hobo.  I'm trying to port a simple Perl application over as my
> first project.  The old site uses a flat file that uses server names
> generated by the website, and another that holds the location
> information (city airport code, description, and last used-number).
> In moving it over to Hobo, my db tables look like:
>
> #The nearest AirPort Code of the location in which the server lives
> apc
>     fields do
>     name :string, :required, :limit => 3
>     description :string
>     timestamps
>   end
>
>   has_many :dc_locs, :dependent => :destroy
>   children :dc_locs
>
> #The Datacenter location
> dc_loc
>   fields do
>     name :string, :required, :limit => 1
>     description :string
>     timestamps
>   end
>
>   belongs_to :apc
>   has_many :servers, :through => :server_assignments, :accessible =>
> true
>   has_many :server_assignments, :dependent => :destroy
>   children :server_assignments
>   children :servers
>
> #The Servers list
> server
>   fields do
>     name     :string
>     user_ip  :string
>     svr_desc :string
>     timestamps
>   end
>
> #An assignment list to put them all together
> server_assignment
>   fields do
>     timestamps
>   end
>
>   belongs_to :server
>   belongs_to :dc_loc
>
> So far so good, everything is playing well together.
> The server names have the apc imbedded in them and a 1 digit dc
> location identifier.
> My main question is:
>
> In the form that I have that edits the dc_loc (location), I'm trying
> to assign server to the dc_loc and I get the select-many list but I
> want to filter that 1200+ list down to just the servers that have the
> apc for that dc_loc in the name.
>
> My application.dryml has:
>
> <extend tag="form" for="DcLoc">
>   <old-form merge>
>     <field-list: fields="name, description, apc, servers">
>       <servers-view:>
>         <select-many options="&@SList"/>
>       </servers-view:>
>     </field-list:>
>   </old-form>
> </extend>
>
> And my dc_locs_controller.rb looks like spaghetti - I've tried many
> things
>
>   #def Svrs
>    # @SList = Server.apply_scopes(
>     #  :search => [this.apc_id, :name]
>    # )
>     #hobo_index @SList
>   #end
>   def edit
>     #hobo_show do
>     @sns = find_instance
>     @SList =
>       @SList = @sns.servers.where(["name
> like ?", :apcs_name[this.apc_id]])
>     #@sn = Server.name_contains(:apcs_name[this.apc_id])
>     #@sn = Server.apply_scopes(:name_contains =>
> params[:name_contains])
>     #@SList = @ss.to_a
>    # end
>   end
>
> end
>
> the latest one gets an error : undefined method `apc_id' for
> nil:NilClass
>
> I've gone through all the tutorials and the recipes on the hobocentral
> site and searched this list until cross-eyed, but each time I try the
> different solutions I'm still getting the same full list (or none at
> all). Each of the tutorials and recipes have been very helpful, but
> not complete when it comes to controlling the exact way to insert
> custom sql code.  I've tried passing name_contains scopes and still
> get the full list with a message in the console that :name_contains is
> being overwritten (probably due to incorrect syntax).
>
> Any assistance would be greatly appreciated.  Even if you point me to
> another place to learn Rails better before I continue.
>
> Regards,
> M

-- 
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