<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-9541852</id><updated>2011-09-28T16:50:22.975-07:00</updated><category term='save_without_transactions'/><category term='ruby'/><category term='apache'/><category term='transaction'/><category term='subclass'/><category term='sql'/><category term='active record'/><category term='connection'/><category term='sanitize_sql_array'/><category term='nginx'/><category term='raw'/><category term='Yii'/><category term='optimization'/><category term='net-ssh'/><category term='parent'/><category term='ssh'/><category term='model'/><category term='CActiveRecord'/><category term='password'/><category term='query conditions'/><category term='database'/><title type='text'>invisilog</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://invisipunk.blogspot.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9541852/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://invisipunk.blogspot.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>invisipunk</name><uri>http://www.blogger.com/profile/03348196418060596240</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>11</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-9541852.post-1525755842259976274</id><published>2011-01-22T10:49:00.000-08:00</published><updated>2011-01-22T11:25:43.311-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='CActiveRecord'/><category scheme='http://www.blogger.com/atom/ns#' term='parent'/><category scheme='http://www.blogger.com/atom/ns#' term='model'/><category scheme='http://www.blogger.com/atom/ns#' term='database'/><category scheme='http://www.blogger.com/atom/ns#' term='Yii'/><category scheme='http://www.blogger.com/atom/ns#' term='subclass'/><title type='text'>Yii's Activerecord subclass model() method</title><content type='html'>I've recently gotten into the Yii PHP framework.  It's a really great MVC framework that makes good use of OOP.  Like many MVC frameworks out there, Yii has its own Activerecord implementation that works great for what I need it do: callbacks, relations, validation, named scopes etc.  There is a bit of a quirk that I noticed with the version of Yii that I am currently using (yii-1.1.6.r2877).  Yii comes with generator to generate the model class for the db table you want to hook into.  Unfortunately the file that the generator creates is the same class where you would add your business logic.  If you want regenerate your model class when you have schema, changes you wind up overwriting your business rules (unless you carefully diff the process).  You could also use the generator to make a base class and then subclass off of that.  Example: UserBase -&gt; User. &lt;br /&gt;Here is an example of how you would use this User subclass.&lt;br /&gt;&lt;blockquote&gt;1. $record=new User;&lt;br /&gt;2. $record=User::model()-&gt;findByPk((int)$id);&lt;/blockquote&gt;&lt;br /&gt;If you use example 1, all your custom methods in User along with rules, etc work just fine.  However if you use example 2 what you get back from model() appears to be an instance of UserBase so you're losing the benefits of subclassing off of UserBase.  Here's what I did to get around this issue.  Add the following to your subclass.&lt;br /&gt;&lt;br /&gt;&lt;blockquote&gt; &lt;br /&gt;        /**&lt;br /&gt; * @return object of current class instead of reverting to parent class&lt;br /&gt; */&lt;br /&gt; public static function model($className=__CLASS__)&lt;br /&gt; {&lt;br /&gt;     $model=new $className(null);&lt;br /&gt;       $model-&gt;_md=new CActiveRecordMetaData($model);&lt;br /&gt;       $model-&gt;attachBehaviors($model-&gt;behaviors());&lt;br /&gt;       return $model;&lt;br /&gt; }&lt;/blockquote&gt;&lt;br /&gt;&lt;br /&gt;I'm using PHP version 5.2 on Windows. I don't know if this will addressed in future versions of Yii. The code in my method came from Yii's source so I can't even explain it in full detail at the moment.  All I can say is that the rules and methods in my subclass work like they are supposed to.  Please feel free to share any comments/concerns about this.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9541852-1525755842259976274?l=invisipunk.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://invisipunk.blogspot.com/feeds/1525755842259976274/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9541852&amp;postID=1525755842259976274' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9541852/posts/default/1525755842259976274'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9541852/posts/default/1525755842259976274'/><link rel='alternate' type='text/html' href='http://invisipunk.blogspot.com/2011/01/yiis-activerecord-subclass-model-method.html' title='Yii&apos;s Activerecord subclass model() method'/><author><name>invisipunk</name><uri>http://www.blogger.com/profile/03348196418060596240</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9541852.post-4457449916428717147</id><published>2009-03-03T17:23:00.000-08:00</published><updated>2009-03-03T17:52:33.191-08:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='ruby'/><category scheme='http://www.blogger.com/atom/ns#' term='password'/><category scheme='http://www.blogger.com/atom/ns#' term='connection'/><category scheme='http://www.blogger.com/atom/ns#' term='ssh'/><category scheme='http://www.blogger.com/atom/ns#' term='net-ssh'/><title type='text'>Ruby Net-SSH connection with just a password</title><content type='html'>I've been trying to use Net-SSH for Ruby on Windows for little while but I couldn't easily find anything useful for my specific usage needs.  What I want to do is to connect to a server using just a password and no keys. I found the information over here. http://net-ssh.rubyforge.org/ssh/v1/chapter-2.html.  The tutorials out there showing password based connection didn't work for me because the behavior I was seeing (at least on Windows) was that net-ssh was looking for a key file even when I didn't want to use one.  Of course using a dss based key file didn't work for me either so I'm set on connecting using just a password.  So here's what worked for me.&lt;br /&gt; &lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Net::SSH.start( 'host', 'user', &lt;br /&gt;:password =&gt; 'passwd', :auth_methods =&gt; ["password"]) do |session|&lt;br /&gt;  session.exec("ls -l")&lt;br /&gt;end&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;From the documentation on the page mentioned above.. &lt;span style="font-style:italic;"&gt;(These are also the only authorization methods that are supported.) If you want them to be tried in a different order, or if you don’t want certain methods to be used, you can specify your own list via this option.&lt;/span&gt;.  Apparently the other methods would not fail-over to password based auth and just die on key auth.   Specifying password authorization as the only method to try worked great for me. Keep in mind, this is only something I've observed on my Windows system so this might be a non-issue for a lot of you.  If you are stuck on this like I was, I hope this was useful.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9541852-4457449916428717147?l=invisipunk.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://invisipunk.blogspot.com/feeds/4457449916428717147/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9541852&amp;postID=4457449916428717147' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9541852/posts/default/4457449916428717147'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9541852/posts/default/4457449916428717147'/><link rel='alternate' type='text/html' href='http://invisipunk.blogspot.com/2009/03/ruby-net-ssh-connection-with-just.html' title='Ruby Net-SSH connection with just a password'/><author><name>invisipunk</name><uri>http://www.blogger.com/profile/03348196418060596240</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9541852.post-3108542152884599368</id><published>2008-08-20T10:25:00.000-07:00</published><updated>2008-08-26T08:12:17.219-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='sanitize_sql_array'/><category scheme='http://www.blogger.com/atom/ns#' term='query conditions'/><category scheme='http://www.blogger.com/atom/ns#' term='active record'/><title type='text'>Sanitize_sql_array</title><content type='html'>The current Rails app I'm working on requires a custom sql in some sections, but writing out query conditions can be hassle sometimes.  Using plain old ActiveRecord queries lets you put in conditions in the form of an array consisting of a simple query string containing question marks which are filled in by the parameter which follow the query string in this conditions array.  &lt;br /&gt;&lt;pre&gt;&lt;br /&gt;Example: &lt;br /&gt;:conditions =&gt; [" foo = ? AND bar = ? AND baz IN (?)", &lt;br /&gt;single_value_1, single_value_2, array_of_values ]&lt;br /&gt;&lt;/pre&gt; &lt;br /&gt;To use this conditions array for my find_by_sql queries I do this.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;conditions_array = [" foo = ? AND bar = ? AND baz IN (?)", &lt;br /&gt;single_value_1, single_value_2, array_of_values ]&lt;br /&gt;condition_string = ActiveRecord::Base.send(&lt;br /&gt;"sanitize_sql_array", conditions_array)&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;Now I have nice condition_string I'm able to use in my custom queries.  I'm not all that experienced with Ruby's handling of scope, so I'm using the send method to access this protected class method.  Let me know if there's a nicer way to do this.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9541852-3108542152884599368?l=invisipunk.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://invisipunk.blogspot.com/feeds/3108542152884599368/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9541852&amp;postID=3108542152884599368' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9541852/posts/default/3108542152884599368'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9541852/posts/default/3108542152884599368'/><link rel='alternate' type='text/html' href='http://invisipunk.blogspot.com/2008/08/sanitizesqlarray.html' title='Sanitize_sql_array'/><author><name>invisipunk</name><uri>http://www.blogger.com/profile/03348196418060596240</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9541852.post-7911857179733127727</id><published>2008-04-19T11:00:00.000-07:00</published><updated>2008-06-30T05:44:46.036-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='sql'/><category scheme='http://www.blogger.com/atom/ns#' term='raw'/><category scheme='http://www.blogger.com/atom/ns#' term='active record'/><category scheme='http://www.blogger.com/atom/ns#' term='optimization'/><title type='text'>ActiveRecord raw insert/update</title><content type='html'>Sometimes, usually for performance reasons, it might be necessary to do raw SQL statements.  Most of the time save_without_transactions is all you might need.  But, if you still want to explicitly call an insert or an update for whatever reason, you're able to use the model connection's execute function.  However, using (ActiveRecord)AR I've gotten quite lazy with writing queries.  Here's something quick dirty I whipped up to generate queries.&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;class ActiveRecord::Base&lt;br /&gt;  def return_value_string(value)&lt;br /&gt;    case value.class.to_s&lt;br /&gt;      when "Time": "'#{value.strftime("%Y-%m-%d %H:%M:%S")}'"&lt;br /&gt;      when "NilClass": "NULL"&lt;br /&gt;      when "Fixnum": value&lt;br /&gt;      when "String": "'#{value.escape_single_quotes}'"&lt;br /&gt;      when "FalseClass": '0'&lt;br /&gt;      when "TrueClass": '1'&lt;br /&gt;      else "'#{value}'"&lt;br /&gt;    end&lt;br /&gt;  end&lt;br /&gt; &lt;br /&gt;  def generate_update_query&lt;br /&gt;    "UPDATE #{self.class.table_name} SET " + &lt;br /&gt;    self.attributes.keys.sort.collect{ |key| &lt;br /&gt;    "`#{key}` = #{return_value_string(self.send(key))}" }.join(", ") + &lt;br /&gt;    " WHERE id = #{self.id}"&lt;br /&gt;  end&lt;br /&gt; &lt;br /&gt;  def generate_insert_query&lt;br /&gt;    @key_vals = self.attributes.collect{ |key,value| &lt;br /&gt;    [key, return_value_string(value)] }&lt;br /&gt;    "INSERT INTO #{self.class.table_name} " +&lt;br /&gt;    "( #{@key_vals.collect{ |item| item[0].to_s }.join(", ") } ) " + &lt;br /&gt;    "VALUES( #{@key_vals.collect{ |item| item[1].to_s }.join(", ") } ) "&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;  def raw_update&lt;br /&gt;    self.class.connection.execute(self.generate_update_query)&lt;br /&gt;  end&lt;br /&gt; &lt;br /&gt;  def raw_insert&lt;br /&gt;    self.class.connection.execute(self.generate_insert_query)&lt;br /&gt;  end&lt;br /&gt; &lt;br /&gt;end&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;br /&gt;Now I can just do object.raw_insert or object.raw_update.  I tried cover most of the data types I can think of in the 'return_value_string' function (I'm working with MySQL), but let me know of anything I might have missed.  Another thing to play with is connection.insert and connection.update.  I believe connection.insert can return the id of the row you just created so that might some slight bit of overhead that can be avoided.  Doing queries this way might be better suited for data migrations rather than normal application requests.  There's still the option of tracing through AR and see how it generates queries but this works well enough for now.  As always, feedback is welcome.&lt;br /&gt;&lt;br /&gt;UPDATE:&lt;br /&gt;here is the revamped version for raw_insert and raw_update ripped directly from activerecord source.  now you can get the id back on your inserts too. yay!&lt;br /&gt;&lt;blockquote&gt;&lt;pre&gt;&lt;br /&gt;def raw_update&lt;br /&gt;  quoted_attributes = attributes_with_quotes(false)&lt;br /&gt;  return 0 if quoted_attributes.empty?&lt;br /&gt;  connection.update(&lt;br /&gt;   "UPDATE #{self.class.table_name} " +&lt;br /&gt;   "SET #{quoted_comma_pair_list(connection, quoted_attributes)} " +&lt;br /&gt;   "WHERE #{connection.quote_column_name(self.class.primary_key)} = #{quote_value(id)}",&lt;br /&gt;   "#{self.class.name} Update"&lt;br /&gt;  )&lt;br /&gt; end&lt;br /&gt; &lt;br /&gt; def raw_insert&lt;br /&gt;  if self.id.nil? &amp;&amp; self.class.connection.prefetch_primary_key?(self.class.table_name)&lt;br /&gt;   self.id = self.class.connection.next_sequence_value(self.class.sequence_name)&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;  quoted_attributes = attributes_with_quotes&lt;br /&gt;&lt;br /&gt;  statement = if quoted_attributes.empty?&lt;br /&gt;   self.class.connection.empty_insert_statement(self.class.table_name)&lt;br /&gt;  else&lt;br /&gt;   "INSERT INTO #{self.class.table_name} " +&lt;br /&gt;   "(#{quoted_column_names.join(', ')}) " +&lt;br /&gt;   "VALUES(#{quoted_attributes.values.join(', ')})"&lt;br /&gt;  end&lt;br /&gt;&lt;br /&gt;  self.id = self.class.connection.insert(statement, "#{self.class.name} Create",&lt;br /&gt;   self.class.primary_key, self.id, self.class.sequence_name)&lt;br /&gt;&lt;br /&gt;  @new_record = false&lt;br /&gt;  id&lt;br /&gt; end&lt;br /&gt;&lt;/pre&gt;&lt;/blockquote&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9541852-7911857179733127727?l=invisipunk.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://invisipunk.blogspot.com/feeds/7911857179733127727/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9541852&amp;postID=7911857179733127727' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9541852/posts/default/7911857179733127727'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9541852/posts/default/7911857179733127727'/><link rel='alternate' type='text/html' href='http://invisipunk.blogspot.com/2008/04/activerecord-raw-insertupdate.html' title='ActiveRecord raw insert/update'/><author><name>invisipunk</name><uri>http://www.blogger.com/profile/03348196418060596240</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9541852.post-6891841198009978020</id><published>2008-04-14T20:24:00.000-07:00</published><updated>2008-04-14T20:45:28.036-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='active record'/><category scheme='http://www.blogger.com/atom/ns#' term='transaction'/><category scheme='http://www.blogger.com/atom/ns#' term='save_without_transactions'/><title type='text'>ActiveRecord sans transactions</title><content type='html'>So we're doing this massive migration from this legacy schema for a client, but our estimates put our import time at around 75 hours.  So I thought transactions should help out but there was a problem.  I'd wrap my insert/update loops with ModelClass.connection.(begin / commit)_db_transaction, but I noticed that every save call would automatically do BEGIN and COMMIT.  After digging around for turning off this behavior at the connection level and getting nowhere, I saw method on my object.  The function "save_without_transactions" was exactly what I was looking for. Of course there wasn't much documentation that I could find on this function.  This might be useful to some newbies going through similar ActiveRecord issues as myself.  This function also comes with the exclamation flavor that throws up an Exception.  Hope this was helpful to someone looking to use ActiveRecord without transactions.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9541852-6891841198009978020?l=invisipunk.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://invisipunk.blogspot.com/feeds/6891841198009978020/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9541852&amp;postID=6891841198009978020' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9541852/posts/default/6891841198009978020'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9541852/posts/default/6891841198009978020'/><link rel='alternate' type='text/html' href='http://invisipunk.blogspot.com/2008/04/activerecord-sans-transactions.html' title='ActiveRecord sans transactions'/><author><name>invisipunk</name><uri>http://www.blogger.com/profile/03348196418060596240</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9541852.post-2799041037609329381</id><published>2008-03-22T18:57:00.000-07:00</published><updated>2008-04-14T20:52:23.753-07:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='nginx'/><category scheme='http://www.blogger.com/atom/ns#' term='apache'/><title type='text'>And the winner is...</title><content type='html'>I've run ab on the current rails project at work using &lt;a href="http://httpd.apache.org/"&gt;Apache&lt;/a&gt; and &lt;a href="http://nginx.net/"&gt;Nginx&lt;/a&gt; as the proxy frontend to a mongrel cluster.  On average I've seen about a 10% increase in performance using Nginx (ymmv).  There's plenty of easy mongrel configurations for Nginx that you can find online.  Working with Fedora, made this extra simple. Yum install, configure, chkconfig to turn on nginx, chkconfig to turn off apache if you already have that on.  More fun to explore is how it does with cached static content.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9541852-2799041037609329381?l=invisipunk.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://invisipunk.blogspot.com/feeds/2799041037609329381/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9541852&amp;postID=2799041037609329381' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9541852/posts/default/2799041037609329381'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9541852/posts/default/2799041037609329381'/><link rel='alternate' type='text/html' href='http://invisipunk.blogspot.com/2008/03/and-winner-is.html' title='And the winner is...'/><author><name>invisipunk</name><uri>http://www.blogger.com/profile/03348196418060596240</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9541852.post-6590042217623725715</id><published>2007-08-28T19:25:00.000-07:00</published><updated>2007-08-30T19:23:20.573-07:00</updated><title type='text'>Rails: calendar_field helper</title><content type='html'>Yet another long overdue update.  I'm currently working at a fun company where I've been doing some Ruby on Rails applications.  We've settled on the javascript calendar from Dynarch for date fields in our projects.  Of course, there's a bit of tedium involved with setting up the calendar for each field you want to use it in.  Hooray for Rails.. my very first helper method eases some of this tedium.  Just copy the two  following functions into your application_helper.rb &lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt; def calendar_field(object_name, method, options = {})&lt;br /&gt;   object = instance_variable_get("@#{object_name}")&lt;br /&gt;   field_value = object.send(method) ? object.send(method).strftime("%m/%d/%Y") : ''&lt;br /&gt;   output = text_field object_name , method , :value =&gt; field_value&lt;br /&gt;   output += calendar_helper(object_name + "_" + method)&lt;br /&gt;   output&lt;br /&gt; end&lt;br /&gt;&lt;br /&gt; def calendar_helper(field_id)&lt;br /&gt;   '&amp;lt;script type="text/javascript"&amp;gt;&lt;br /&gt;             Calendar.setup({&lt;br /&gt;             inputField     :    "'+ field_id  + '",   // id of the input field&lt;br /&gt;             ifFormat       :    "%m/%d/%Y",       // format of the input field&lt;br /&gt;             showsTime      :    false,&lt;br /&gt;             timeFormat     :    "24",&lt;br /&gt;             singleClick       :        true&lt;br /&gt;             });&lt;br /&gt;           &amp;lt;/script&amp;gt;'&lt;br /&gt; end&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;and call it in your views like so&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;br /&gt;&lt;pre&gt;&lt;br /&gt;&amp;lt;%= calendar_field 'object', 'method'  %&amp;gt;&lt;br /&gt;&lt;/pre&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;Sure, you can combine both functions into one and add a date format as a param but so  far this serves my quick and dirty needs.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9541852-6590042217623725715?l=invisipunk.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://invisipunk.blogspot.com/feeds/6590042217623725715/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9541852&amp;postID=6590042217623725715' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9541852/posts/default/6590042217623725715'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9541852/posts/default/6590042217623725715'/><link rel='alternate' type='text/html' href='http://invisipunk.blogspot.com/2007/08/rails-calendarfield-helper.html' title='Rails: calendar_field helper'/><author><name>invisipunk</name><uri>http://www.blogger.com/profile/03348196418060596240</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9541852.post-115742575841499621</id><published>2006-09-04T14:55:00.000-07:00</published><updated>2006-09-04T20:09:18.523-07:00</updated><title type='text'>Beginning with Xoops</title><content type='html'>So I just recently finished a contract job where they wanted a whole portal type deal with wiki, blog, forum etc. And they wanted all of this managed under centralized login ala CMS.  After some digging, I landed on the &lt;a href="http://www.xoops.org/"&gt;Xoops&lt;/a&gt; page.  This is a real neat project which makes it possible to integrate other php web apps such as mediawiki, wordpress etc.  Some of the software I wanted to try out would only work well with xoops-2.2.3a-Final.  Here's some little tweaks I had to do along the way to make things work just right.&lt;br /&gt;&lt;br /&gt;Mediawiki in the xoops environment does lock out anonymous users from making edits, however you can't seem to restrict edit access to any particular user group(s) from xoops.&lt;br /&gt;&lt;br /&gt;This little workaround did it for me.  Mind you there's probably a nicer way to do it but the quick and dirty method worked for me.&lt;br /&gt;In mediawiki/includes/User.php I modified the isAllowed function (which seems to get run on every page load) as such.&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;&lt;/span&gt;&lt;blockquote&gt;&lt;span style="font-family:courier new;"&gt;function isAllowed($action='') {&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;                if ( $action === '' )&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;                        // In the spirit of DWIM&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;                        return true;&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;                $this-&gt;loadFromDatabase();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;                global $xoopsUser;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;                ini_set("register_globals", "on");&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;                #checking for edit page, edit action and whether user is logged in&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;                if( ($_GET['action'] == "edit") &amp;&amp;amp; ($action == "edit") &amp;&amp;amp; ($this-&gt;mId) &amp;&amp;amp;  is_object($xoopsUser)  )&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;                {&lt;br /&gt;$usergroups  = &lt;/span&gt;&lt;span style="font-family:courier new;"&gt;$xoopsUser-&gt;getGroups();&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;                        #check if admin or a developer&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;                        if(  in_array( 1  , $usergroups )  ||  in_array( 4  , $usergroups )  ){&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;  return true;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;                        }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;                        else{&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;  #deny edit access&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;  return false;&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;                        }&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;                }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;                else{&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;                        return in_array( $action , $this-&gt;mRights );&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;                }&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;        }&lt;/span&gt;&lt;/blockquote&gt;`&lt;br /&gt;&lt;br /&gt;All I do right now is check for the usergroup ID's I'm interested in that big if statement but ideally you can build your array of ID's that you want to give access to and compare against. This is an exercise I leave upto you.&lt;br /&gt;&lt;br /&gt;Another module that needed some work was the Edito module.  This provides a nice and neat way to post static content on the site.  There's even hooks to use an HTML editor. However this module didn't seem to even get to the install part right (I'm doing this on a Linux machine, not sure what the behavior is on Windows).  The best thing to do before doing the install is turn on the debug mode in xoops.  Right away I noticed that permission problems were keeping me from loading the module.&lt;br /&gt;Moving on ..&lt;br /&gt;In edito/admin/index.php&lt;br /&gt;I changed.&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;include_once ("../include/nav.php");&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;include_once("../include/myblockslist.php");&lt;/span&gt;&lt;br /&gt;to...&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;include_once ("../../include/nav.php");&lt;/span&gt;&lt;br /&gt;&lt;span style="font-family:courier new;"&gt;include_once("../../include/myblockslist.php&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Hope this was actually helpfull to someone. Let me know what you guys think.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9541852-115742575841499621?l=invisipunk.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://invisipunk.blogspot.com/feeds/115742575841499621/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9541852&amp;postID=115742575841499621' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9541852/posts/default/115742575841499621'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9541852/posts/default/115742575841499621'/><link rel='alternate' type='text/html' href='http://invisipunk.blogspot.com/2006/09/beginning-with-xoops.html' title='Beginning with Xoops'/><author><name>invisipunk</name><uri>http://www.blogger.com/profile/03348196418060596240</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9541852.post-112352377685959198</id><published>2005-08-08T10:12:00.000-07:00</published><updated>2005-08-14T13:16:44.906-07:00</updated><title type='text'>Linksys WUSB11 in Debian GNU/Linux</title><content type='html'>Been meaning to write this for a while now and by this point most of the information isn't even fresh in my mind so please bear with me...Hopefully this debian method will make your life a tad bit easier... So here we go...&lt;br /&gt;I'm lazy so I'm using a stock kernel. If you are doing the same, get the matching kernel headers package (I'm using 2.6, should work with late 2.4s... I wouldn't even try 2.2). Another thing to note is that the verion of the WUSB11 I am using is ver 2.8. Hopefully this will be useful for WUSB11s in general. First, you can apt-get some important components.&lt;br /&gt;# apt-get install gcc hotplug at76c503a-source atmel-firmware wireless-tools module-assistant modconf&lt;br /&gt;&lt;br /&gt;That's about it for packages.. as far my recollection goes. Next you need to build the module. The easiest way to this is ..&lt;br /&gt;# module-assistant auto-install at76c503a&lt;br /&gt;&lt;br /&gt;This should compile the module against the matching headers for your kernel. If you want to compile it against another kernel .. I'm sure it's possible by editing stuff in the source directory for at76c503a. If all goes well, you should see a deb package for the kernel module in your /usr/src directory. Use dpkg -i to install this package. You might see the results of this in dmesg. Use modconf and make sure you select this module. This puts the module into /etc/modules to load when you startup. (yes, editing the file by hand also works..). It might not be quite there yet. There might be a line in hotplug that you need to change so it can properly load the firmware upon loading the module. Try running..&lt;br /&gt;#/etc/init.d/hotplug restart&lt;br /&gt;&lt;br /&gt;Then take a look at dmesg and proceed.&lt;br /&gt;&lt;br /&gt;If things don't look right.  The line you are looking for in /etc/init.d/hotplug is&lt;br /&gt;#echo /sbin/hotplug &gt; /proc/sys/kernel/hotplug   .... you just need to uncomment this line and restart hotplug.&lt;br /&gt;&lt;br /&gt;The line that needs to be edited in the hotplug startup script might be fixed by now. If so, you won't see any issues about not being able to find the firmware. Also, don't forget to update your /etc/network/interfaces with the information for your new interface.. such as the WEP the key. You can also put the info in /etc/network/if-pre-up.d/wireless-tools . Good luck.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9541852-112352377685959198?l=invisipunk.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://invisipunk.blogspot.com/feeds/112352377685959198/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9541852&amp;postID=112352377685959198' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9541852/posts/default/112352377685959198'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9541852/posts/default/112352377685959198'/><link rel='alternate' type='text/html' href='http://invisipunk.blogspot.com/2005/08/linksys-wusb11-in-debian-gnulinux.html' title='Linksys WUSB11 in Debian GNU/Linux'/><author><name>invisipunk</name><uri>http://www.blogger.com/profile/03348196418060596240</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9541852.post-111048282273184470</id><published>2005-03-10T11:00:00.000-08:00</published><updated>2008-06-08T13:32:27.415-07:00</updated><title type='text'>Manorama in Firefox</title><content type='html'>If you want to view http://www.manoramaonline.com in firefox, the steps to accomplish this is very easy.  These steps work in linux and in windows.  &lt;br /&gt;First you want to install the Manorama font. http://geocities.com/peringz/fonts/manorama.zip&lt;br /&gt;&lt;br /&gt;For Linux users, make sure you have true type font support. In Debian this is fairly easy by installing the right packages.  Most stock linux distro should come with all the support you need out of the box. On Debian if you install ttf-malayalam-fonts package, it provides a nice place to store the Manorama.ttf file.&lt;br /&gt;/usr/share/fonts/truetype/ttf-malayalam-fonts/ is where I put my font file.&lt;br /&gt;&lt;br /&gt;In windows XP you can use, c:\WINDOWS\Fonts .  I'm pretty sure this is the directory for other versions of windows as well.&lt;br /&gt;&lt;br /&gt;Next you need to install an extension for AutoCharacterCoding switching for Malayalam in Firebird/Mozilla from http://quicktools.mozdev.org.  That's it.  Restart firefox and try out http://www.manoramaonline.com.  There's a delay from when it initially loads the page and then switches the character coding, but this is only a small annoyance for me.  Let me know if you kids come across any issues. Later.&lt;br /&gt;&lt;br /&gt;UPDATE: Just use the Padma extension.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9541852-111048282273184470?l=invisipunk.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://invisipunk.blogspot.com/feeds/111048282273184470/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9541852&amp;postID=111048282273184470' title='6 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9541852/posts/default/111048282273184470'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9541852/posts/default/111048282273184470'/><link rel='alternate' type='text/html' href='http://invisipunk.blogspot.com/2005/03/manorama-in-firefox.html' title='Manorama in Firefox'/><author><name>invisipunk</name><uri>http://www.blogger.com/profile/03348196418060596240</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>6</thr:total></entry><entry><id>tag:blogger.com,1999:blog-9541852.post-110987025151317030</id><published>2005-03-03T09:13:00.000-08:00</published><updated>2005-03-03T09:17:31.513-08:00</updated><title type='text'>First Post</title><content type='html'>My first post on blogger. Huzzah.  Not much to discuss right.  This blog will be used primarily to discuss tech related news in my life.  At the moment, things of interest are XMLhttp especiallly in conjunction with PHP, Ubuntu linux, random hardware.  I'll have something more interesting in the next post. bye..&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/9541852-110987025151317030?l=invisipunk.blogspot.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://invisipunk.blogspot.com/feeds/110987025151317030/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=9541852&amp;postID=110987025151317030' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/9541852/posts/default/110987025151317030'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/9541852/posts/default/110987025151317030'/><link rel='alternate' type='text/html' href='http://invisipunk.blogspot.com/2005/03/first-post.html' title='First Post'/><author><name>invisipunk</name><uri>http://www.blogger.com/profile/03348196418060596240</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='http://img2.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry></feed>
