Rails Webapp stuff
Configuration: db
Db migrations
Active record
Validations
Controller, routing
View, layouts
scaffold now generates useful code
Helper functions in views
Sessions, storing sessions
Error reporting and logging - the "flash"
Wednesday, June 24, 2009
Tuesday, June 2, 2009
Ivy
all you need if Ivy is properly installed is to define an XML namespace in your Ant file (xmlns:ivy="antlib:org.apache.ivy.ant"). Then all the Ivy ant tasks will be available in this namespace
http://ant.apache.org/ivy/history/2.1.0-rc1/tutorial/start.html
Without any settings, Ivy retrieves files from the maven 2 repository. That's what happened here.
The resolve task has found the commons-lang and commons-cli modules in the maven 2 repository, identified that commons-cli depends on commons-logging and so resolved it as a transitive dependency. Then Ivy has downloaded all corresponding artifacts in its cache (by default in your user home, in a .ivy2/cache directory). Finally, the retrieve task copies the resolved jars from the ivy cache to the default library directory of the project: the lib dir (you can change this easily by setting the pattern attribute on the retrieve task).
Configurations are very important concept in ivy. They allow you to group artifacts by meaning.
When you write ivy file for projects that are supposed to be reused, use configurations to allow people to get only they what they need without having to specify it by hand using artifact tag in dependency section.
http://ant.apache.org/ivy/history/2.1.0-rc1/tutorial/start.html
Without any settings, Ivy retrieves files from the maven 2 repository. That's what happened here.
The resolve task has found the commons-lang and commons-cli modules in the maven 2 repository, identified that commons-cli depends on commons-logging and so resolved it as a transitive dependency. Then Ivy has downloaded all corresponding artifacts in its cache (by default in your user home, in a .ivy2/cache directory). Finally, the retrieve task copies the resolved jars from the ivy cache to the default library directory of the project: the lib dir (you can change this easily by setting the pattern attribute on the retrieve task).
Configurations are very important concept in ivy. They allow you to group artifacts by meaning.
When you write ivy file for projects that are supposed to be reused, use configurations to allow people to get only they what they need without having to specify it by hand using artifact tag in dependency section.
Monday, June 1, 2009
Agile Rails Development Book
Ajax
use form_remote_tag helper instead of button_to
use respond_to instead of redirect_to in controller and create a rjs file - which is some ruby from which javascript is generated. The js is then interpreted on the ajax response.
Partial templates - you can pass it a collection and it will render it once for every item in the collection.
Partials should be in the same directory as the template that calls it. Name should start with an underscore.
Partial has a default variable with same name as the filename of the partial, which is set to each item of the collection. Strange.
Every controller has a logger attribute
A flash is a bucket
(actually closer to a Hash) in which you can store stuff as you process a request.
The contents of the flash are available to the next request in this session
before being deleted automatically.
This tells us that it’s generally a really bad idea to store application-level
objects in session data. Any change to the application could potentially require
us to lose existing sessions when we next update the application in production.
Instead, the recommended practice is to store only simple data in the session:
strings, numbers, and so on. Keep your application objects in the database,
and then reference them using their primary keys from the session data. If we
were rolling the Depot application into production, we’d be wise to make the
Cart class an Active Record object and store cart data in the database.5 The
session would then store the cart object’s id.
makes session available to u in controller with session map
the button_to method also links a
view back to the application, but it does so by generating an HTML form that
contains just a single button. When the user clicks the button, an HTTP POST
request is generated. And a POST request is just the ticket when we want to
do something like add an item to a cart.
Use the following to force http delete
Double quotes with %{ }
Use decimal instead of float for numbers
rake db:migrate [VERSION=0]
rake db:sessions:clear
rake db:migrate:redo
Handle escape characters:
Something about suppressing blank lines in the script output
ERbisafilterthat takesan.erbfileandoutputsatransformedversion. The
outputfileisoftenHTMLinRails, but it canbeanything.
Create view files that have same name as action files
After installing a new version of Rails, you might also want to update the files
that Rails initially added to your applications (the JavaScript libraries it uses
for Ajax support, various scripts, and so on). You can do this by running the
following command in your application’s top-level directory:
rubys> rake rails:update
What are test fixtures?
Ways Rails beats EJB:
use form_remote_tag helper instead of button_to
use respond_to instead of redirect_to in controller and create a rjs file - which is some ruby from which javascript is generated. The js is then interpreted on the ajax response.
Partial templates - you can pass it a collection and it will render it once for every item in the collection.
Partials should be in the same directory as the template that calls it. Name should start with an underscore.
Partial has a default variable with same name as the filename of the partial, which is set to each item of the collection. Strange.
Every controller has a logger attribute
A flash is a bucket
(actually closer to a Hash) in which you can store stuff as you process a request.
The contents of the flash are available to the next request in this session
before being deleted automatically.
This tells us that it’s generally a really bad idea to store application-level
objects in session data. Any change to the application could potentially require
us to lose existing sessions when we next update the application in production.
Instead, the recommended practice is to store only simple data in the session:
strings, numbers, and so on. Keep your application objects in the database,
and then reference them using their primary keys from the session data. If we
were rolling the Depot application into production, we’d be wise to make the
Cart class an Active Record object and store cart data in the database.5 The
session would then store the cart object’s id.
makes session available to u in controller with session map
the button_to method also links a
view back to the application, but it does so by generating an HTML form that
contains just a single button. When the user clicks the button, an HTTP POST
request is generated. And a POST request is just the ticket when we want to
do something like add an item to a cart.
<%= number_to_currency(product.price) %>
Use the following to force http delete
<%= link_to 'Destroy', product, :confirm => 'Are you sure?', :method => :delete %>
Double quotes with %{ }
Use decimal instead of float for numbers
rake db:migrate [VERSION=0]
rake db:sessions:clear
rake db:migrate:redo
Handle escape characters:
Email: <%= h("Ann & Bill frazers@isp.email") %>
Something about suppressing blank lines in the script output
ERbisafilterthat takesan.erbfileandoutputsatransformedversion. The
outputfileisoftenHTMLinRails, but it canbeanything.
Create view files that have same name as action files
After installing a new version of Rails, you might also want to update the files
that Rails initially added to your applications (the JavaScript libraries it uses
for Ajax support, various scripts, and so on). You can do this by running the
following command in your application’s top-level directory:
rubys> rake rails:update
What are test fixtures?
Ways Rails beats EJB:
- automatically adds class methods for find, update, delete etc to model objects
Subscribe to:
Posts (Atom)