http://jsfiddle.net/ramiror/fTtUA/ remove markers: my_marker.setMap(null) Programatically create a dialog box: $.mobile.changePage( “page for the dialog content”, { role: “dialog”} );
Monthly Archives: November 2012
Ruby on Rails: sessions
Browser sessions are handled the following way: session[:remember_token] = user.id And then, on each page view, you can do a check for them as follows: User.find(session[:remember_token]) To reset a session in rails, use: reset_session
Ruby on Rails: SSL configuration
Inside config/environments/production.rb: config.force_ssl = true
Ruby on Rail: Flash messages
It’s basically a messaging system that flashes messages for a few seconds on page loads. In the controller, you usually load the flash messages like this: flash[:success] = “Welcome to the Sample App!” And in the views (usually a designated place in the layout view), you can display it as: <% flash.each do |key, value| %> […]
Ruby On Rails: database stuff
Since you are dealing with the database layer through the Models, you usually don’t need to worry about direct access to that layer, but here are a few commands to cleanup stuff: bundle exec rake db:reset // Truncates the database tables bundle exec rake db:test:prepare // To prepare the data for tests rake db:seed # take the data from […]
Ruby on Rails: routes
resources :users Basically, adding the line above to your config/routes.rb will make sure that REST style urls are available to access the User model. If you have a line like: get “users/new” in your router, you can remove it now, since the resource line will take care of adding all the “add”, “create”, “update”, “delete” capabilities […]
Ruby on Rais: rails environments
Code to detect what environment the page is running on, and act accordingly: <%= debug(params) if Rails.env.development? %> In the console: > Rails.env Will print the environment you are running in: “production”, “test” or “development”