Son of the Inventory AppBut firstThree PossibilitiesInstallationMigrate to productionConfigurationVirtual HostOdds and EndsTonight and Next WeekWhen we left our applicationLet's take a look at the sourceNext StepsStatusnew.html.erbedit.html.erbA validationdate_submittedWhat's the difference?date_selectAnother ValidationFirst Try: 1 day ago and ErrThis WorksRefining Date AppearanceUsing strftimestrftime formattingRefining our indexSearchesSimple SearchThe inputThe InputAn if to catch the searchfindfind_by_sql()Refining a findCombining codePowerPoint PresentationOne more thingAdvanced SearchA simple pageordered.html.erbTry to load ita better findmachine.erbsearch.erbOk?search/index.html.erbSlide 47machine controllerA basic working searchA selectionselect_tagSlide 52Our constantSo far so goodChanged to an ArrayController vs ModelCall Method from ControllerBack to our general searchSlide 59SourcesSon of the Inventory AppSon of the Inventory AppBut firstBut firstThe question came up about how to run a production server with Rails…The question came up about how to run a production server with Rails…Three PossibilitiesThree PossibilitiesUse fastcgi and apacheUse apache as a proxy server, against a cluster of mongrel servers (this is covered in Agile Web Development with Rails)And the one you want, passenger:http://www.modrails.com/I'm still playing with this, more to come…Use fastcgi and apacheUse apache as a proxy server, against a cluster of mongrel servers (this is covered in Agile Web Development with Rails)And the one you want, passenger:http://www.modrails.com/I'm still playing with this, more to come…InstallationInstallationIt's a gem so use "sudo gem install passenger"Then run:sudo passenger-install-apache2-moduleThis will install the modules neededIt's a gem so use "sudo gem install passenger"Then run:sudo passenger-install-apache2-moduleThis will install the modules neededMigrate to productionMigrate to productionrake migrate RAILS_ENV=production This will create a new empty database for a production serverYou can copy your development db over the production one if you want to carry your test data over, or dump and load the datarake migrate RAILS_ENV=production This will create a new empty database for a production serverYou can copy your development db over the production one if you want to carry your test data over, or dump and load the dataConfigurationConfigurationIn the apache config file, check to make sure you have the modules loadingI had to add these manually on my laptopIn the apache config file, check to make sure you have the modules loadingI had to add these manually on my laptopLoadModule passenger_module /usr/local/lib/ruby/gems/1.8/LoadModule passenger_module /usr/local/lib/ruby/gems/1.8/ gems/passenger-2.0.3/ext/apache2/mod_passenger.sogems/passenger-2.0.3/ext/apache2/mod_passenger.so# Passenger config# Passenger configPassengerRoot /usr/local/lib/ruby/gems/1.8/gems/passenger-2.0.3PassengerRoot /usr/local/lib/ruby/gems/1.8/gems/passenger-2.0.3PassengerRuby /usr/local/bin/rubyPassengerRuby /usr/local/bin/rubyVirtual HostVirtual HostYou need to define a virtual hostThis is what I’m using for nowNote that I’m using podzone.net, this is dyndnsThe base uri should point to a soft link to your application's public folder--doesn't work for meYou need to define a virtual hostThis is what I’m using for nowNote that I’m using podzone.net, this is dyndnsThe base uri should point to a soft link to your application's public folder--doesn't work for me<VirtualHost *:80><VirtualHost *:80> ServerAdmin [email protected] [email protected] DocumentRoot /Library/WebServer/DocumentsDocumentRoot /Library/WebServer/Documents RailsBaseURI /inventoryRailsBaseURI /inventory RailsSpawnMethod conservativeRailsSpawnMethod conservative ServerName avatar.podzone.netServerName avatar.podzone.net</VirtualHost></VirtualHost>Odds and EndsOdds and EndsAfter configuring the web server, restart it:sudo apachectl gracefulWatch your logs:tail -f /var/log/httpd/error_logAfter configuring the web server, restart it:sudo apachectl gracefulWatch your logs:tail -f /var/log/httpd/error_logTonight and Next WeekTonight and Next WeekTonighttime and datetagslots searchesNext Weekmore searchesemailfilesystem access?Tonighttime and datetagslots searchesNext Weekmore searchesemailfilesystem access?When we left our applicationWhen we left our applicationA database backendSome MigrationsPlayed with TypesPlayed with Time MethodsSome ValidationsA database backendSome MigrationsPlayed with TypesPlayed with Time MethodsSome ValidationsLet's take a look at the sourceLet's take a look at the sourceModelControllerViewsModelControllerViewsNext StepsNext StepsRefine status optionsRefine date_submittedAdd searchesRefine status optionsRefine date_submittedAdd searchesStatusStatusWe can't depend on the user to type what we wantSo we need to define what statuses we'll acceptordered, delivered, deployedProvide a controlled method for selectionRadio buttonsWe can't depend on the user to type what we wantSo we need to define what statuses we'll acceptordered, delivered, deployedProvide a controlled method for selectionRadio buttonsnew.html.erbnew.html.erbIn the views/machine dir, we need to edit new.html.erb fileThis one's easy, note we're setting a defaultIn the views/machine dir, we need to edit new.html.erb fileThis one's easy, note we're setting a default <p><p> <%= f.label :status %><br /><%= f.label :status %><br /> <%= f.radio_button :status, "ordered", :checked => true %><%= f.radio_button :status, "ordered", :checked => true %> Ordered <br/>Ordered <br/> <%= f.radio_button :status, "delivered" %>Delivered <br/><%= f.radio_button :status, "delivered" %>Delivered <br/> <%= f.radio_button :status, "deployed" %>Deployed <br/><%= f.radio_button :status, "deployed" %>Deployed <br/> </p></p>edit.html.erbedit.html.erbFor the edit view, the same thing without the defaultFor the edit view, the same thing without the default <p><p> <%= f.label :status %><br /><%= f.label :status %><br /> <%= f.radio_button :status, "ordered" %>Ordered <br/><%= f.radio_button :status, "ordered"
View Full Document