Posted in Uncategorized | Leave a Comment »
http://www.ruby-forum.com/topic/64948#74373
Here is a sample of application.rb:
require 'gettext/rails'
class ApplicationController < ActionController::Base
prepend_before_filter :default_locale
def default_locale
if (cookies["lang"].nil? or cookies["lang"].empty?)
GetText.locale = "zh_CN"
else
GetText.locale = cookies["lang"]
end
end
init_gettext "yourapp"
end
Posted in Uncategorized | Leave a Comment »
After seeing how schools organize their programs, it looks like I need to re-organize how I store the relevant data
1. Schools: In the school table I’ll keep track of:
- what languages taught (language_id)
- what kinds of courses taught (course_type_id)
These two columns will actually be join tables, since each school will not have a set number of languages or course types they teach, and also because the total number of languages and course types across all schools will change. By using join tables it’ll be easier to add new languages and course types.
A second benefit will be that the it’ll become easier to implement the pull-down search menus that are giving me so much trouble, since now all the data needed to create the pull-down menus will be in only one table instead of being spread between the schools & courses tables.
The drawback will be that the meta-information about what languages and types of courses each school offers will not be directly linked to the actual courses the school offers. For example, it might be possible for a school to say they offer courses in, say, Chinese and/or business conversation, but not actually offer any such courses. But the chances of that happening are slim. I’ll make sure that when school administrators log in, they’ll see an overview of their school’s info, and hopefully they’ll notice anything outdated.
2. Courses table will have:
- id
- school_id
- language_id
- title_en
- title_ja
- description_en
- description_ja
Posted in Uncategorized | Leave a Comment »
<h4>session</h4><%= debug(session) %>
<h4>params</h4><%= debug(params) %>
<h4>response</h4><%= debug(response) %>
Or, add to controller:
render_text @params.inspect
Posted in Uncategorized | Leave a Comment »
On Windows, MySQL returns true/false, and on Dreamhost 1/0. I'd sure like to know how to get Windows to return 1/0.
Posted in Uncategorized | Leave a Comment »
Dreamhost wiki instructions are here.
Create a new subdomain, make the web directory subdomain.domain.com/public
Delete the logs.
Edit public/.htaccess, change dispatch.cgi to .fcgi in the RewriteRule
Default is production. so edit config/environment.rb, add ENV['RAILS_ENV'] ||= 'development' (or production, and create corresponding database)
In dispatch.fcgi and dispatch.rb, change ruby shebang location to #!/usr/bin/ruby
Upload the app's directories to the subdomain's root directory.
edit config/database.yml
chmod -R u+rwX,go-w public logchmod a+x dispatch.fcgi
If you're running in production mode, do 'killall -9 ruby' a few times after making any changes to the code.
Posted in Uncategorized | Leave a Comment »
Question: What’s the media parameter in a stylesheet tag for?
Question: How do I use the same stylesheet but a different javascript file for each action?
HTML escape can be written <%=h product.title %> or <%= h(product.title)>
Notice the difference between the two:
<%= link_to ‘Add to Cart’, :action => ‘add_to_cart’, :id => product %>
<%= link_to ‘Add to Cart’, {:action => ‘add_to_cart’, :id => product }, :class => ‘addtocart’ %>
The curly brackets prevent the class declaration from being part of the URL.
Posted in Uncategorized | Leave a Comment »