From spike at indra.com Thu Oct 1 14:59:16 2009 From: spike at indra.com (Spike Ilacqua) Date: Thu, 01 Oct 2009 12:59:16 -0600 Subject: [Boulder Ruby Group] Office For Rent Message-ID: <4AC4FC04.4040608@indra.com> I have a spare office available if anyone is looking for some space. Nice office, conference room and kitchen use, parking, and lots of bandwidth (we're an ISP). I'm the lone developer here and it would be nice to have peers around. Details: http://boulder.craigslist.org/off/1392135704.html I'll throw in a couple of Us in our data center as well. ->Spike From rsc at indra.com Thu Oct 1 19:25:45 2009 From: rsc at indra.com (Robert Campbell) Date: Thu, 1 Oct 2009 17:25:45 -0600 Subject: [Boulder Ruby Group] RoR question In-Reply-To: <4AC4FC04.4040608@indra.com> References: <4AC4FC04.4040608@indra.com> Message-ID: <6FC6DC35-7722-4FE5-B1E9-1E719D5DD2A1@indra.com> Hey everyone, I'm either blind to the obvious, or I'm being overly complicated. I created a site that tracks events. Originally (out of ease and speed) I created a text field for the location of the event. My users (rightly) got tired of doing the copy/paste shuffle every time they wanted to create a new event. As there were only a handful of locations being used I figured it would be nice to break out the locations into their own model/controller and create a one-to-many association (event has one location, location has many events). This way, I can switch the location selection in the event form to a drop- down. Easy! The events table now has a location_id foreign key and there's a "belongs_to :location" in the events model. The locations model has a "has_many :events" but it doesn't seem really necessary; there's no need or desire from the users to list the events by location. I've added it simply because every single example of a one-to-many association is built that way, though from what I' can tell "has_many" does not require anything in the locations table, it only generates a method that runs through the events table looking for a matching id in the locations_id foreign-key column. (eg: @location.events Follow? :) ) So to just to get things rolling, in views/events/show.html.erb I have the following section:

<%= @event.location.name %>
<%= @event.location.address1 %>
<%= @event.location.address2 %>
<%= @event.location.city %>, <%= @event.location.state %>
<%= @event.location.zip %>
<%= @event.location.other %>

(there is also a location.label, which is a short nickname used in the location drop-down) Anyway, I figured it would be much more DRY to just call the "show" view/action in the Locations controller from within the "show" view for an event. IE, when I "show" and event, it "show"s the location. Nice and OO right? It's either not so easy, or I'm off in left field. The closest I can get is <%= render 'locations/show' %> but of course @location isn't set, so that does nothing. I tried adding "@location = Locations.find(@event.location_id)" to the show action in the Events controller, so that the above render would have a @location when it got to the view, but I get the error "uninitialized constant EventsController::Locations". (also tried find_by_id) Not sure what to do, but since I've been banging my head against this for two days, I'm a bit numb. Overload a 'find' method in my Location model (not the controller, the model)? I hate leaving it as above, but I since the ugly works, I'll just put white-out on my screen whenever I edit that file. All thoughts welcome! Bob Campbell From kevin at activ8.us Thu Oct 1 23:33:05 2009 From: kevin at activ8.us (Kevin Marvin) Date: Thu, 1 Oct 2009 22:33:05 -0500 Subject: [Boulder Ruby Group] RoR question In-Reply-To: <6FC6DC35-7722-4FE5-B1E9-1E719D5DD2A1@indra.com> References: <4AC4FC04.4040608@indra.com> <6FC6DC35-7722-4FE5-B1E9-1E719D5DD2A1@indra.com> Message-ID: <4150FC5D-8CAE-4726-8EA6-91095B7866C1@activ8.us> Bob: Not sure that I follow what youare looking for here, but either way I interpret it, you are looking for a shared partial. Do this... in the app/views directory create a 'shared' directory, if one doesn't already exist. Make it something like: shared/location.rhtml (sorry, too old school to do the .erb thing) In it, place a simple block:

<%= location.name %>
<%= location.address1 %>
... etc ...

Then, in a view that comes from the event controller, you can do:

Event

<%= @event.name %>
<%= @event.contact_info %>
<%= render :partial => "shared/location", :object => @event.location (or :locals => {:location => @event.location}) %>
... etc ... In the location controller, you can also use it, pushing @location into :object (or whatever). There is more info here: http://api.rubyonrails.org/classes/ActionView/Partials.html and here: http://snippets.dzone.com/posts/show/6863 If you have any questions, feel free to shoot me an email. Thanks, - Kevin On Oct 1, 2009, at 6:25 PM, Robert Campbell wrote: > Hey everyone, I'm either blind to the obvious, or I'm being overly > complicated. > > I created a site that tracks events. Originally (out of ease and > speed) I created a text field for the location of the event. My > users (rightly) got tired of doing the copy/paste shuffle every time > they wanted to create a new event. As there were only a handful of > locations being used I figured it would be nice to break out the > locations into their own model/controller and create a one-to-many > association (event has one location, location has many events). > This way, I can switch the location selection in the event form to a > drop-down. Easy! > > The events table now has a location_id foreign key and there's a > "belongs_to :location" in the events model. The locations model has > a "has_many :events" but it doesn't seem really necessary; there's > no need or desire from the users to list the events by location. > I've added it simply because every single example of a one-to-many > association is built that way, though from what I' can tell > "has_many" does not require anything in the locations table, it only > generates a method that runs through the events table looking for a > matching id in the locations_id foreign-key column. (eg: > @location.events Follow? :) ) > > So to just to get things rolling, in views/events/show.html.erb I > have the following section: >

> <%= @event.location.name %>
> <%= @event.location.address1 %>
> <%= @event.location.address2 %>
> <%= @event.location.city %>, <%= @event.location.state %>
> <%= @event.location.zip %>
> <%= @event.location.other %>
>

> (there is also a location.label, which is a short nickname used in > the location drop-down) > > Anyway, I figured it would be much more DRY to just call the "show" > view/action in the Locations controller from within the "show" view > for an event. IE, when I "show" and event, it "show"s the > location. Nice and OO right? > > It's either not so easy, or I'm off in left field. > > The closest I can get is <%= render 'locations/show' %> but of > course @location isn't set, so that does nothing. I tried adding > "@location = Locations.find(@event.location_id)" to the show action > in the Events controller, so that the above render would have a > @location when it got to the view, but I get the error > "uninitialized constant EventsController::Locations". (also tried > find_by_id) > > Not sure what to do, but since I've been banging my head against > this for two days, I'm a bit numb. Overload a 'find' method in my > Location model (not the controller, the model)? I hate leaving it > as above, but I since the ugly works, I'll just put white-out on my > screen whenever I edit that file. > > All thoughts welcome! > > > Bob Campbell > > > _______________________________________________ > Bdrg-members mailing list > Bdrg-members at rubyforge.org > http://rubyforge.org/mailman/listinfo/bdrg-members -- XML is like violence, if it doesn?t solve your problem you?re not using enough of it. ?Anonymous From fred at fredjean.net Thu Oct 1 23:54:55 2009 From: fred at fredjean.net (Frederic Jean) Date: Thu, 01 Oct 2009 21:54:55 -0600 Subject: [Boulder Ruby Group] RoR question In-Reply-To: <4150FC5D-8CAE-4726-8EA6-91095B7866C1@activ8.us> References: <4AC4FC04.4040608@indra.com> <6FC6DC35-7722-4FE5-B1E9-1E719D5DD2A1@indra.com> <4150FC5D-8CAE-4726-8EA6-91095B7866C1@activ8.us> Message-ID: <4AC5798F.6050601@fredjean.net> Kevin Marvin wrote: > Bob: > > Not sure that I follow what youare looking for here, but either way I > interpret it, you are looking for a shared partial. > > Do this... in the app/views directory create a 'shared' directory, if > one doesn't already exist. Make it something like: > > shared/location.rhtml (sorry, too old school to do the .erb thing) Just a nit... You will need to start the file name with an underscore for Rails to recognize it as a partial. shared/_location.html.erb (I'm definitively not old school) would work. Fred > > In it, place a simple block: > >

<%= location.name %>
> <%= location.address1 %>
> > ... etc ... > >

> > > Then, in a view that comes from the event controller, you can do: > >

Event

> <%= @event.name %>
> <%= @event.contact_info %>
> <%= render :partial => "shared/location", :object => @event.location > (or :locals => {:location => @event.location}) %>
> > ... etc ... > > In the location controller, you can also use it, pushing @location > into :object (or whatever). > > There is more info here: > http://api.rubyonrails.org/classes/ActionView/Partials.html > > and here: > > http://snippets.dzone.com/posts/show/6863 > > If you have any questions, feel free to shoot me an email. > > Thanks, > > - Kevin > > On Oct 1, 2009, at 6:25 PM, Robert Campbell wrote: > >> Hey everyone, I'm either blind to the obvious, or I'm being overly >> complicated. >> >> I created a site that tracks events. Originally (out of ease and >> speed) I created a text field for the location of the event. My users >> (rightly) got tired of doing the copy/paste shuffle every time they >> wanted to create a new event. As there were only a handful of >> locations being used I figured it would be nice to break out the >> locations into their own model/controller and create a one-to-many >> association (event has one location, location has many events). This >> way, I can switch the location selection in the event form to a >> drop-down. Easy! >> >> The events table now has a location_id foreign key and there's a >> "belongs_to :location" in the events model. The locations model has a >> "has_many :events" but it doesn't seem really necessary; there's no >> need or desire from the users to list the events by location. I've >> added it simply because every single example of a one-to-many >> association is built that way, though from what I' can tell >> "has_many" does not require anything in the locations table, it only >> generates a method that runs through the events table looking for a >> matching id in the locations_id foreign-key column. (eg: >> @location.events Follow? :) ) >> >> So to just to get things rolling, in views/events/show.html.erb I >> have the following section: >>

>> <%= @event.location.name %>
>> <%= @event.location.address1 %>
>> <%= @event.location.address2 %>
>> <%= @event.location.city %>, <%= @event.location.state %>
>> <%= @event.location.zip %>
>> <%= @event.location.other %>
>>

>> (there is also a location.label, which is a short nickname used in >> the location drop-down) >> >> Anyway, I figured it would be much more DRY to just call the "show" >> view/action in the Locations controller from within the "show" view >> for an event. IE, when I "show" and event, it "show"s the location. >> Nice and OO right? >> >> It's either not so easy, or I'm off in left field. >> >> The closest I can get is <%= render 'locations/show' %> but of course >> @location isn't set, so that does nothing. I tried adding "@location >> = Locations.find(@event.location_id)" to the show action in the >> Events controller, so that the above render would have a @location >> when it got to the view, but I get the error "uninitialized constant >> EventsController::Locations". (also tried find_by_id) >> >> Not sure what to do, but since I've been banging my head against this >> for two days, I'm a bit numb. Overload a 'find' method in my Location >> model (not the controller, the model)? I hate leaving it as above, >> but I since the ugly works, I'll just put white-out on my screen >> whenever I edit that file. >> >> All thoughts welcome! >> >> >> Bob Campbell >> >> >> _______________________________________________ >> Bdrg-members mailing list >> Bdrg-members at rubyforge.org >> http://rubyforge.org/mailman/listinfo/bdrg-members > > > -- > XML is like violence, if it doesn?t solve your problem you?re not > using enough of it. ?Anonymous > > _______________________________________________ > Bdrg-members mailing list > Bdrg-members at rubyforge.org > http://rubyforge.org/mailman/listinfo/bdrg-members From rsc at indra.com Fri Oct 2 00:04:30 2009 From: rsc at indra.com (Robert Campbell) Date: Thu, 1 Oct 2009 22:04:30 -0600 Subject: [Boulder Ruby Group] RoR question In-Reply-To: <042971F2-6F01-4EA8-8878-2AEAE159B8CC@factorylabs.com> References: <4AC4FC04.4040608@indra.com> <6FC6DC35-7722-4FE5-B1E9-1E719D5DD2A1@indra.com> <042971F2-6F01-4EA8-8878-2AEAE159B8CC@factorylabs.com> Message-ID: <9AF7408B-91C3-498B-AB32-22E352EE1DE4@indra.com> On Oct 1, 2009, at 7:50 PM, gabe.varela at factorylabs.com wrote: > Should just be @location = @event.location. You have a typo in that > Locatios.find is plural instead of singular. Ha! That worked. :) On Oct 1, 2009, at 8:39 PM, Cameron Pope wrote: > Bob - > > Unless I'm not understanding your question, I think this is exactly > what Partials were designed to do: let you keep a snippet of erb > code to render locations with the rest of the views for locations > and then let you call it from anywhere. Right, and I'll probably shift to partial, but the catch when using render is that it does not execute the other controller's action code. So, if you have controller XYZ with action 'show' and a show.html.erb, "render XYZ/show" will choke if it depends on a variable set in action XYZ.show. So even a partial would have choked. The secret above is that "@location = @event.location" needs to be set in the show action of the Events controller, which i suppose is fine since I've defined the one-to-many association (an event must have a location) but it doesn't seem to me to be cleanly OO. (?) Of course, as soon as I get the answer, I discover something else that works. From http://guide.rails.info/layouts_and_rendering.html: ---- Every partial also has a local variable with the same name as the partial (minus the underscore). You can pass an object in to this local variable via the :object option: <%= render :partial => "customer", :object => @new_customer %> Within the customer partial, the customer variable will refer to @new_customer from the parent view. ---- :| I swear I read that section twice and didn't see that little tidbit. So! What I've got now is, <%= render :partial => 'locations/location', :object => @event.location %> after copying show.html.erb to _location.html.erb, and changed all the "@location.xyz" refs to "location.xyz" (eg: location.name, etc). That works! I can actually feel myself getting smarter. You guys are awesome. Thanks! Bob Campbell From mghaught at gmail.com Sun Oct 18 23:28:54 2009 From: mghaught at gmail.com (Marty Haught) Date: Sun, 18 Oct 2009 21:28:54 -0600 Subject: [Boulder Ruby Group] BRG - October Meeting Reminder - Oct 21st Message-ID: <57f29e620910182028n143611f9u42c7e57f41d20b70@mail.gmail.com> October 21st at 7pm Boulder Ruby will have its usual monthly meeting. Wanna write Ruby scripts like a ninja? Come join us and let Ara Howard show you how to be scripting Ruby like an assassin of the night. Maybe you'll want to pick up a ninja suit for Halloween to go with your new scripting fu in Ruby. The meeting will begin with our usual sugar attack (pre-Halloween) and conversation. If you have any announcements to share with the group bring them along and remind me before I release Ara's deadly scripting assaults. Hope to see you all out there. Cheers, Marty Haught http://boulderruby.org Directions: Collective Intellect 1433 Pearl St, Suite 200 Boulder, CO 80302 The office is behind and above Starbucks on Pearl. The entrance is on Pearl Street just east of Starbucks, behind the statue of the wolf. Come straight through all the doors. URL to google maps: http://rubyurl.com/pKfB From mghaught at gmail.com Tue Oct 27 17:25:02 2009 From: mghaught at gmail.com (Marty Haught) Date: Tue, 27 Oct 2009 15:25:02 -0600 Subject: [Boulder Ruby Group] Freelancers looking for work Message-ID: <57f29e620910271425p3e909121qbe390c9a59f8f91f@mail.gmail.com> Hey Guys, I get asked here and there for references to Rails consultants that are open for contract work. I talk to many of you and know who's open for new work and who's busy. I figured it might be easier to email both groups. If you'd like me to refer work to you can you email me offlist? Some of the work is local, some of it is remote. Thanks. Cheers, Marty From Joe at obility.net Sat Oct 31 13:14:25 2009 From: Joe at obility.net (Joe Scharf) Date: Sat, 31 Oct 2009 11:14:25 -0600 Subject: [Boulder Ruby Group] Looking for developer for web application project Message-ID: <06552E8B-5D89-48CA-8C3C-B19629BEBE4B@obility.net> Hi all, I am building a small developer / designer team to build a web application for a client of mine. I plan to have the site done in Rails and am looking for an experienced developers that would be interested in bidding on the project. If interested, please contact me and I can send you the project proposal with the details. Thanks -- Joe Scharf Obility, LLC The Internet Engineering Company PO Box 19425 Boulder, CO 80308 303-552-0223 812-OBILITY (google voice) 303-648-6152 (fax) www.obility.net -------------- next part -------------- An HTML attachment was scrubbed... URL: