start serverSOFTWARE: railsruby script/server lighttpd fire up a rails server. run this command when in the directory of your rails app. MORE INFO:update search indexSOFTWARE: railsruby script/indexer update simplesearch index for rails (run from inside your app's directory) MORE INFO:text area styleSOFTWARE: rails<%= text_area 'record', 'reason', :style => "width: 400px; height: 200px" %> explicitly specify the style of a text area in rails
MORE INFO: default blank date for date_selectSOFTWARE: rails<%= date_select(:record, :reviewed_at, :include_blank => 1 %> let's you designate a blank value as the default for a date_select in rails.
MORE INFO: destroy childrenSOFTWARE: railshas_many: comments, :dependent => :destroy Code in the model to destroy children if the parent is destroyed. In other words, make sure you're not left with orphan records.
MORE INFO: generate scaffoldSOFTWARE: railsscript/generate scaffold Item Item Generate a scaffold based on a given table in the db in rails. The example would generate a model and controller as the uppercase single (Item) named version of the related lowercase plural (items) table in the database. MORE INFO:clear logsSOFTWARE: railsrake log:clear clear the logs. usefull to make your app smaller if you're moving it around between dev instances and things. MORE INFO:create migrationSOFTWARE: railsscript/generate migration Rating Create a migration file in rails. MORE INFO:restart rails on site5 serverSOFTWARE: railsskill -9 -u username -c dispatch.fcgi Use this command to restart fast cgi processes on site5 hosted servers. Insert your username in place of 'username' in the example. MORE INFO:generate rails docsSOFTWARE: railsrake appdoc generate documentation for your rails app. I've also seen this as "rake doc:app". Also this might be useful at some point to generate docs for plugins: "rake doc:plugins". Apparently you can rebuild docs with "rake doc:reapp". MORE INFO:rails deploymentSOFTWARE: railsdeployment notes on for rails at site5I ended up freezing rails to the vendor directory by using
I also froze all third party gems (search etc) by using the great script here: This required a bit of tweaking to make sure that files that used to call a gem directly would now instead reference the appropriate file in the /lib directory. (freeze gems puts rails in the vendor dir, but freeze other gems puts them into the /lib directory.) General tutorials for deployment at site5MORE INFO:rails orphansSOFTWARE: railsat the model levelMake the parent set to destroy dependent children if the parent is destroyed. Add this to the parent's model.rb file:
So it would look something like:
set alert at controller level for usersFound this code online. Could be used to set a flash alert to notify users that they can't destroy something because it has children ...
MORE INFO: rails ratingsSOFTWARE: railsstar rating system notesTutorial here: software: rails subject: order options list Was having some issues trying to get options in a selection form list to come out the way I wanted. Found that the method:
is set, whereas the more generic method find can be modified like so to provide some additional details:
MORE INFO: rdoc documentationSOFTWARE: railsYou can run rake appdoc to generate automatic documentation for your rails app. There are two main areas to add documentation to your app. One is a general description which gives you a main doc page. The other is inline in your code via comments which is useful for describing details of how specifics are set up. The Main Doc PageTo add general notes about your rails app to the auto-generated documentation, add them to the file doc/README_FOR_APP. The contents of this file get sucked into the generated documentation when you run rake appdoc from the shell. Your documentation gets created in doc/app with an index page at doc/app/index.html. Any content that you place in doc/README_FOR_APP shows up in the main frame of the index page for your documentation. Use the Styling guidelines listed below to markup doc/README_FOR_APP and you will end up with a nicely formatted main page for your documentation. This is a great place to add the general info regarding your app. Inline Code DocumentationTo add documentation for classes and methods in your app, add comments (comments start with the pound sign in your code). The placement of the comments determines where they'll show up in the documentation. To add a description for a class: add comments ABOVE the class declaration in your code.
To add a description for a method: add comments ABOVE the method declaration in your code.
Styling the Documentationheadings are equal signs (as in alternate MarkDown syntax) lists (note the period after a digit - req'd)
paragraphs: consecutive lines of type code: indent (as in MarkDown syntax) markup
definition lists
MORE INFO: order options listSOFTWARE: railsWas having some issues trying to get options in a selection form list to come out the way I wanted. Found that the method:
is set, whereas the more generic method find can be modified like so to provide some additional details:
MORE INFO: date time formatSOFTWARE: railsobject.created_at.strftime("%a, %b %d '%y") Use the strftime method to format date-time the way you like. In the nugget I'm assuming that 'object' has a 'created_at' column in the database so I'm running strftime on that to make it look pretty. You could also just run on something like this:
Terry Donaghe has published a nice list of available arguments here: MORE INFO: http://www.rubynoob.com/articles/2006/08/31/how-to-do-friendly-date-formatting-in-rubyforeign key searchSOFTWARE: railsadd method to model to define foreign searchable field Here's how I made a foreign key table value searchable with simple search in rails. First make up a method name for the thing you want searched in the foreign key table and add to model "make_searchable" line:
Then, define "foreign_value" later in the model so make_searchable knows what to look for:
This assumes you have some foreign key table (foreigns) and it has a column called "name" that you're accessing. Of course you'll need the proper relationship between the tables in the model like:
But you'll probably have that in your model already. This was a simple extension of the idea provided in the comments of the post in the ref url for this cheat - /bin/recykl- (it was for ferret instead of simple search.) MORE INFO: http://blog.zmok.net/articles/2006/10/18/full-text-search-in-ruby-on-rails-3-ferretundefined method 'require_gem'SOFTWARE: railschange 'require_gem' to 'gem' in code Just replace 'require_gem' method with 'gem' and you're good to go. MORE INFO: |