Google Code SVN

roland's picture

Install svn. If on windows you want to add the path where svn is installed to your path variables.

SVN in windows:
Right click on "My Computer" and go to Properties. Then go to "Advanced" -> "Environment Variables". Browse in the second list to "Path" and edit it. The paths are ";" delimited. So add your path there. Something like this ;C:\Program Files\Subversion\bin

I created a rails app and then checked out in same folder the google project.

svn co https://project_name.googlecode.com/svn/trunk/ project_name --username user_name

Then

cd project_name

svn add *

svn commit -m "Initial Import"

And voila.

Class Hierarchy

roland's picture

Well, Rails enables you to inherit from classes. However other than inheriting methods, I don't see how this inheritance helps with roles if the same tables are used to pull data from.

Sort_by

roland's picture

Really cool ruby feature to sort with:


# descending
@students.sort_by{|s| Time.now-s.created_at}
# ascending
@students.sort_by{|s| s.created_at-Time.now}

Datebocks with Prototype Windows Class

roland's picture

So, I've been playing with the Prototype windows Class and the DateBocks plugin.

Well, I found out a very strange problem. When loading a script through a Ajax Updater into a div, Firefox fails to set a variable if it is set with "var variable_name".

after modifying:


script type="text/javascript">
var #{calendar_ref}Obj = new DateBocks(
#{options_for_javascript(datebocks_options)}
);
/script>

to


script type="text/javascript">
#{calendar_ref}Obj = new DateBocks(
#{options_for_javascript(datebocks_options)}
);
/script>

Note that there's no "var".
That enabled me to set a variable that controlled
the datebocks.

I don't know if it's a browser problem or a script
problem. Both statements should be equivalent.

Javascript windows with prototype

roland's picture

This project is breath taking

http://prototype-window.xilinus.com/index.html

Getting it to work wasn't that easy, but I managed to successfully install it.

Jorge Díaz has apparently written a rails helper but it isn't that great.

http://xurde.info/index.php/uncategorized/prototype-window-class-helper....

Well, it didn't do all I needed it to do so, I hacked my way in.

Instructions.

1. Copy the rails helper in your_app_path/lib.

2. Add in your application_helper.rb

include PrototypeWindowClassHelper

3. Modify the link_to_prototype_window to

def link_to_prototype_window( name, window_id, content = "", options = { :windowParameters => {} } , html_options = {} )

#window_id must be unique and it's destroyed on window close.
#options for this helper: http://prototype-window.xilinus.com/documentation.html#initialize
content.gsub!("\'","LOL'").gsub!("LOL","\\").gsub!("\n", "")
js_code ="var win = new Window( '#{window_id}', #{params_for_javascript(options) } ); win.getContent().innerHTML = #{array_or_string_for_javascript(content)}; win.showCenter(); win.setDestroyOnClose();"
content_tag(
"a", name,
html_options.merge({
:href => html_options[:href] || "#",
:onclick => (html_options[:onclick] ? "#{html_options[:onclick]}; " : "") + js_code }))
end

So you can pass some content in the window.

3. Include the javascript libraries and themes. The themes folder goes into your stylesheets folder in public.

    
  

Ruby on Rails U.S. State List

roland's picture

Nice list of states in the US from

http://www.bigbold.com/snippets/posts/show/908

module State  NAMES = [    [ "Alabama", "AL" ],     [ "Alaska", "AK" ],     [ "Arizona", "AZ" ],     [ "Arkansas", "AR" ],     [ "California", "CA" ],     [ "Colorado", "CO" ],     [ "Connecticut", "CT" ],     [ "Delaware", "DE" ],     [ "District Of Columbia", "DC" ],     [ "Florida", "FL" ],     [ "Georgia", "GA" ],     [ "Hawaii", "HI" ],     [ "Idaho", "ID" ],     [ "Illinois", "IL" ],     [ "Indiana", "IN" ],     [ "Iowa", "IA" ],     [ "Kansas", "KS" ],     [ "Kentucky", "KY" ],     [ "Louisiana", "LA" ],     [ "Maine", "ME" ],     [ "Maryland", "MD" ],     [ "Massachusetts", "MA" ],     [ "Michigan", "MI" ],     [ "Minnesota", "MN" ],     [ "Mississippi", "MS" ],     [ "Missouri", "MO" ],     [ "Montana", "MT" ],     [ "Nebraska", "NE" ],     [ "Nevada", "NV" ],     [ "New Hampshire", "NH" ],     [ "New Jersey", "NJ" ],     [ "New Mexico", "NM" ],     [ "New York", "NY" ],     [ "North Carolina", "NC" ],     [ "North Dakota", "ND" ],     [ "Ohio", "OH" ],     [ "Oklahoma", "OK" ],     [ "Oregon", "OR" ],     [ "Pennsylvania", "PA" ],     [ "Rhode Island", "RI" ],     [ "South Carolina", "SC" ],     [ "South Dakota", "SD" ],     [ "Tennessee", "TN" ],     [ "Texas", "TX" ],     [ "Utah", "UT" ],     [ "Vermont", "VT" ],     [ "Virginia", "VA" ],     [ "Washington", "WA" ],     [ "West Virginia", "WV" ],     [ "Wisconsin", "WI" ],     [ "Wyoming", "WY" ]  ]end

It seems some one has collected a list of states in many different countries such as
US, India, Canada, Australia and Spain
and people are adding more to it.

Well, I'd rather stick with the list above.

Oh if you were wondering how to generate the select, probably

<%= select 'object', 'state', State::NAMES %>

Apache 2.2 mod_proxy mogrel_rails

roland's picture

To set up the proxy in apache to send requests to mongrel rails do the following:

1. Start a web server on a port other than 80.

cd /path/to/your/app
mongrel_rails start -d -p 9001

2. Enable mod_proxy. In Ubuntu you only need to do:

a2enmod proxy

3. Configure apache like this:

NameVirtualHost *:80
<Proxy *>
Order allow,deny
Allow from all
</Proxy>
<VirtualHost *:80>
ServerName mysite
ProxyPass / http://127.0.0.1:9001/
ProxyPassReverse / http://127.0.0.1:9001/
</VirtualHost>

4. Make sure that mysite is in /etc/hosts

One click ruby installer

roland's picture

I tried both 1.8.4 - 16 and 17 but both had very serious problems in windows...

So, I really don't suggest you use them except for 1.8.2... however, the latest version of mongrel requires 1.8.4..

Syndicate content