<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>redconfettilinkedin | redconfetti</title>
	<atom:link href="http://www.redconfetti.com/tag/linkedin/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.redconfetti.com</link>
	<description>the journal of maxwell keyes</description>
	<lastBuildDate>Tue, 24 Jan 2012 17:04:22 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Configuring Rails 3.1.3 under Sub-URI</title>
		<link>http://www.redconfetti.com/2012/01/configuring-rails-3-1-3-under-sub-uri/</link>
		<comments>http://www.redconfetti.com/2012/01/configuring-rails-3-1-3-under-sub-uri/#comments</comments>
		<pubDate>Wed, 04 Jan 2012 06:02:40 +0000</pubDate>
		<dc:creator>redconfetti</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[linkedin]]></category>
		<category><![CDATA[rails3.1]]></category>
		<category><![CDATA[relative_url_root]]></category>
		<category><![CDATA[sub-uri]]></category>

		<guid isPermaLink="false">http://www.redconfetti.com/?p=969</guid>
		<description><![CDATA[In setting up a new Rails app recently I was told that it needed to be served under the sub-URI of &#8216;/info&#8217;. I hadn&#8217;t done this before with a Rails app, and I expected that it could be tricky. I checked online to see how this is done and found references to the &#8216;relative_url_root&#8217; setting,...]]></description>
			<content:encoded><![CDATA[<p>In setting up a new Rails app recently I was told that it needed to be served under the sub-URI of &#8216;/info&#8217;. I hadn&#8217;t done this before with a Rails app, and I expected that it could be tricky.</p>
<p>I checked online to see how this is done and found references to the &#8216;relative_url_root&#8217; setting, but then shortly found that this has been deprecated.</p>
<p>I&#8217;m using Phusion Passenger with Apache 2, so I inserted the following configuration into my VirtualHost entry for the site.</p>
<pre class="brush:text">
Alias /info /home/myapp/current/public
&lt;Location /info&gt;
  PassengerAppRoot /home/myapp/current
  RailsEnv production
&lt;/Location&gt;
</pre>
<p>The Rails application was expecting requests from the root of the site still. I found a StackOverflow article where someone suggested configuring all the routes under the &#8220;/info&#8221; scope like so:</p>
<pre class="brush:rails">
# config/routes.rb
scope "/info" do
  root :to =&gt; "welcome#index"
  resources :posts
end
</pre>
<p>This worked fine in development mode. I just made sure to pull up the pages using http://localhost:3000/info/</p>
<p>I had tested this in production before building out the application further, and it seemed to work fine. Later on when I deployed after many updates, I found that the application was referencing precompiled assets using &#8216;/assets/&#8217; and not &#8216;/info/assets/&#8217;. Further investigation pointed out that I needed to configure assets with a prefix like so:</p>
<pre class="brush:rails">
# config/application.rb
config.assets.prefix = "/info/assets"
</pre>
<p>This seemed like it would help, but this caused assets to be precompiled under &#8216;public/info/assets&#8217;.</p>
<p>I had previously Googled for &#8216;rails 3.1 subdirectory path&#8217;, not registering that the more appropriate keyword is &#8216;sub URI&#8217; for what I&#8217;m trying to accomplish.</p>
<p>It turns out that the best way to do this with Passenger is to mount the application to the sub-URI using the proper Apache configuration, and leave it up to the Rack interface to handle serving the requests to the Rails application, without using any Rails application configuration for the sub-URI.</p>
<p>I removed the scoped routes, and the assets prefix, returning my application to it&#8217;s default configuration. I then created a symbolic link for &#8216;info&#8217; in the websites DocumentRoot, pointing to the &#8216;public&#8217; folder of my application as per the <a href="http://www.modrails.com/documentation/Users%20guide%20Apache.html#deploying_rack_to_sub_uri" target="_blank">Passenger documentation</a>.</p>
<pre class="brush:shell">
ln -s /home/myapp/current/public /home/mysite/public_html/info
</pre>
<p>I added the appropriate configuration into my VirtualHost entry as advised by the Passenger documentation, but this only worked for the root of the website, not my admin area I had wanted to serve from /info/admin/. All I got was a 404 page from the main site.</p>
<p>I found that the following configuration worked perfectly, with the symbolic link still needing to be present.</p>
<pre class="brush:text">
Alias /info /home/myapp/current/public
&lt;Location /info&gt;
  PassengerAppRoot /home/myapp/current
  RackEnv production
  RackBaseURI /info
&lt;/Location&gt;
</pre>
<p>You might notice that I&#8217;m using &#8216;RackEnv production&#8217; instead of &#8216;RailsEnv production&#8217;. This is because I recall at some point previously that Rails 3.0 applications are Rack Applications, and thus you have to use &#8216;RackEnv&#8217; instead for Passenger to load the application in the proper environment mode.</p>
<hr />
<p>Update 01/04/12: I&#8217;m using the <a href="https://github.com/spohlenz/tinymce-rails" target="_blank">TinyMCE-Rails plugin</a> to provide a WYSIWYG editor for one of the resources in my application. It&#8217;s not loading in production however (surprise, surprise). I checked into the precompiled Javascript file being served from the live server, and I see it includes the following:</p>
<pre class="brush:javascript">
window.tinyMCEPreInit=window.tinyMCEPreInit||{base:"/assets/tinymce",query:"3.4.7",suffix:""}
</pre>
<p>The &#8216;base&#8217; value should be &#8216;/info/assets/tinymce&#8217;. I see that in the TinyMCE-Rails gem the coding for this is:</p>
<pre class="brush:rails">
window.tinyMCEPreInit = window.tinyMCEPreInit || {
  base:   '<%= Rails.application.config.assets.prefix %>/tinymce',
  query:  '<%= TinyMCE::VERSION %>',
  suffix: ''
};
</pre>
<p>All call to &#8216;asset_path(&#8216;rails.png&#8217;)&#8217; in production returns &#8216;/info/assets/rails-e4b51606cd77fda2615e7439907bfc92.png&#8217; so Rails is honoring the RackSubURI setting configured for Passenger. The following returns the same path.</p>
<p>The reason why this works is that the Rails asset helpers pull the relative_url_root value from the controller configuration, which must receive it from the Rack configuration. When deploying the app using Capistrano, such configuration is not present, and thus the correct path cannot be included in the precompiled assets.</p>
<p>The issue was reported via Git hub in issue #<a href="https://github.com/rails/rails/issues/3259" target="_blank">3259</a> and #<a href="https://github.com/rails/rails/issues/2435" target="_blank">2435</a>, and a fix will was implemented in Rails 3.2, with a possibly backport to Rails 3.1.4. </p>
<p>It appears that you&#8217;ll need to add a configuration to your application.rb or environments/production.rb, depending on how your development and production environments are setup.</p>
<pre class="brush:rails">
# config/environments/production.rb

# Use sub-uri in production
config.relative_url_root = '/info'
</pre>
<p>Or possibly configure your deployment script to include the environment variable when precompiling.</p>
<pre class="brush:shell">
RAILS_RELATIVE_URL_ROOT="/info" bundle exec rake assets:precompile
</pre>
<p>I wanted to test this, but I can&#8217;t seem to update to Rails 3.2, or install a new Rails app using edge Rails.</p>
<pre class="brush:shell">
rails new testapp --edge
.
.
.
Bundler could not find compatible versions for gem "actionpack":
  In Gemfile:
    sass-rails (>= 0) ruby depends on
      actionpack (~> 3.1.0) ruby

    rails (>= 0) ruby depends on
      actionpack (4.0.0.beta)
</pre>
<p>I&#8217;m just going to configure my app under a subdomain instead of sub-uri for now.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.redconfetti.com/2012/01/configuring-rails-3-1-3-under-sub-uri/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Troubleshooting ActiveResource Requests</title>
		<link>http://www.redconfetti.com/2012/01/troubleshooting-activeresource-requests/</link>
		<comments>http://www.redconfetti.com/2012/01/troubleshooting-activeresource-requests/#comments</comments>
		<pubDate>Sun, 01 Jan 2012 22:46:52 +0000</pubDate>
		<dc:creator>redconfetti</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[ActiveResource]]></category>
		<category><![CDATA[HighRise]]></category>
		<category><![CDATA[linkedin]]></category>
		<category><![CDATA[REST API]]></category>

		<guid isPermaLink="false">http://www.redconfetti.com/?p=947</guid>
		<description><![CDATA[I&#8217;m currently working on an app which integrates with the HighRise API using the Highrise Ruby wrapper gem. The classes defined by the gem rely on ActiveResource, the Ruby library included with Rails for interfacing with RESTful resources like the HighRise API. Sometimes I&#8217;m not sure if the requests being made via the commands I&#8217;m...]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m currently working on an app which integrates with the <a href="http://developer.37signals.com/highrise/people" target="_blank">HighRise API</a> using the <a href="https://github.com/tapajos/highrise" target="_blank">Highrise Ruby wrapper gem</a>. The classes defined by the gem rely on ActiveResource, the Ruby library included with Rails for interfacing with RESTful resources like the HighRise API.</p>
<p>Sometimes I&#8217;m not sure if the requests being made via the commands I&#8217;m using are making the right calls on the HighRise API.</p>
<p>I found this thread on StackOverflow: <a href="http://stackoverflow.com/questions/227907/how-do-i-view-the-http-response-to-an-activeresource-request" target="_blank">How do I view the HTTP response to an ActiveResource request?</a>. The solution I found helpful was this one on <a href="http://www.jroller.com/bokmann/entry/debugging_activerecord_web_services" target="_blank">overriding ActiveResource::Connection</a> so that it outputs the debug output. This worked for me even with Rails 3.1.</p>
<p>Just in case this article with the code disappears, here is the initializer code you can use to view the HTTP session data from the console. I&#8217;ve added an if statement to make sure the HTTP data is only outputted to the standard output in development mode, for <a href="http://ruby-doc.org/stdlib-1.9.3/libdoc/net/http/rdoc/Net/HTTP.html#method-i-set_debug_output" target="_blank">security purposes</a>, as well as requires the environment variable &#8216;HTTPDEBUG&#8217;.</p>
<pre class="brush:rails"># /config/initializers/connection.rb
class ActiveResource::Connection
  # Creates new Net::HTTP instance for communication with
  # remote service and resources.
  def http
    http = Net::HTTP.new(@site.host, @site.port)
    http.use_ssl = @site.is_a?(URI::HTTPS)
    http.verify_mode = OpenSSL::SSL::VERIFY_NONE if http.use_ssl
    http.read_timeout = @timeout if @timeout
    #Here's the addition that allows you to see the output
    if Rails.env == 'development' &amp;&amp; ENV['HTTPDEBUG']
      http.set_debug_output $stderr
    end
    return http
  end
end</pre>
<p>You can open the Rails console using &#8216;HTTPDEBUG=true rails c&#8217; to activate the console with debugging output displayed in the console mode.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.redconfetti.com/2012/01/troubleshooting-activeresource-requests/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Example Rake Task</title>
		<link>http://www.redconfetti.com/2012/01/example-rake-task/</link>
		<comments>http://www.redconfetti.com/2012/01/example-rake-task/#comments</comments>
		<pubDate>Sun, 01 Jan 2012 22:26:28 +0000</pubDate>
		<dc:creator>redconfetti</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[linkedin]]></category>
		<category><![CDATA[rake]]></category>

		<guid isPermaLink="false">http://www.redconfetti.com/?p=943</guid>
		<description><![CDATA[Here is example rake task code which you can use and modify the next time you&#8217;re setting up new Rake tasks for a Rails app from scratch. The example includes the syntax for setting the default task, running multiple tasks in order, and a task which includes multiple arguments. This coding syntax works with Rails...]]></description>
			<content:encoded><![CDATA[<p>Here is example rake task code which you can use and modify the next time you&#8217;re setting up new Rake tasks for a Rails app from scratch. The example includes the syntax for setting the default task, running multiple tasks in order, and a task which includes multiple arguments. This coding syntax works with Rails 3.1.</p>
<pre class="brush:rails"># /lib/tasks/mytask.rake
namespace :mytask do

  task :default =&gt; 'mytask:full_run'

  desc "run all tasks in proper order"
  task :full_run =&gt; [:example_task_one, :example_task_two] do
    puts "All tasks ran and completed at #{Time.now}"
  end

  desc "example task without arguments"
  task :example_task_one =&gt; :environment do
    # task code goes here
    puts "Example Task One completed"
  end

  desc "example task with arguments"
  task :example_task_two, [:arg1, :arg2] =&gt; :environment do |t, args|
    # if no arguments, display docs
    if args.count == 0
      puts ''
      puts "rake mytask:example_task[arg1,arg2]"
      puts "arg1: description of first argument"
      puts "arg2: description of second argument"
      puts ''
      puts "example:"
      puts "rake mytask:example_task[123,'456']"
      puts ''
    else
      # task code goes here
      puts "Running task with arg1: #{args.arg1}, and arg2: #{args.arg2}"
      puts "Example Task Two completed"
    end
  end
end</pre>
<p>Special thanks to Jason Seifer for his <a href="http://jasonseifer.com/2010/04/06/rake-tutorial" target="_blank">Rake Tutorial</a> which made this possible.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.redconfetti.com/2012/01/example-rake-task/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Adding a New User in Ubuntu</title>
		<link>http://www.redconfetti.com/2011/12/adding-a-new-user-in-ubuntu/</link>
		<comments>http://www.redconfetti.com/2011/12/adding-a-new-user-in-ubuntu/#comments</comments>
		<pubDate>Thu, 29 Dec 2011 18:15:35 +0000</pubDate>
		<dc:creator>redconfetti</dc:creator>
				<category><![CDATA[Ubuntu]]></category>
		<category><![CDATA[linkedin]]></category>

		<guid isPermaLink="false">http://www.redconfetti.com/?p=939</guid>
		<description><![CDATA[Adding User When setting up a new website manually on an Ubuntu server you need to establish a user account with a home directory, and Bash shell access to the server. useradd -m testuser -s /bin/bash After creating the account you&#8217;ll want to assign a password for the account. passwd testuser]]></description>
			<content:encoded><![CDATA[<h2>Adding User</h2>
<p>When setting up a new website manually on an Ubuntu server you need to establish a user account with a home directory, and Bash shell access to the server.</p>
<pre class="brush:shell">useradd -m testuser -s /bin/bash</pre>
<p>After creating the account you&#8217;ll want to assign a password for the account.</p>
<pre class="brush:shell">passwd testuser</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.redconfetti.com/2011/12/adding-a-new-user-in-ubuntu/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Resolving issues with Namespaced Models in Rails 3.1.0</title>
		<link>http://www.redconfetti.com/2011/12/resolving-issues-with-namespaced-models-in-rails-3-1-0/</link>
		<comments>http://www.redconfetti.com/2011/12/resolving-issues-with-namespaced-models-in-rails-3-1-0/#comments</comments>
		<pubDate>Tue, 06 Dec 2011 23:09:51 +0000</pubDate>
		<dc:creator>redconfetti</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[linkedin]]></category>
		<category><![CDATA[namespaced models]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[rails3.1]]></category>

		<guid isPermaLink="false">http://www.redconfetti.com/?p=929</guid>
		<description><![CDATA[I recently was tasked with upgrading an application from Rails 2.3.8 to Rails 3. I choose to upgrade it to Rails 3.1, because why upgrade once and then have to do it again later. After upgrading and testing many points of the system locally, I was ready to push the upgraded application to the production...]]></description>
			<content:encoded><![CDATA[<p>I recently was tasked with upgrading an application from Rails 2.3.8 to Rails 3. I choose to upgrade it to Rails 3.1, because why upgrade once and then have to do it again later.</p>
<p>After upgrading and testing many points of the system locally, I was ready to push the upgraded application to the production server. After pushing it out I started to notice that a certain rake task was failing to run via a cronjob I had setup. This rake task worked with certain non-ActiveRecord models, which I had setup with a hierarchy which utilized inheritance and namespacing.</p>
<p>Under Rails 2.3.8 I had a file, /app/models/rets_map/rets_map_base.rb. The error I was receiving from the rake task involved some sort of issue loading the class from this file.</p>
<p>As an experiment I renamed the file as &#8216;base.rb&#8217; so that it&#8217;s path was /app/models/rets_map/base.rb. I figured that Rails 3.1.0 expected this naming convention. I was right, kind of&#8230;</p>
<pre class="brush:shell">$ rails console
/Users/jason/Sites/rj4/rails/app/controllers/site_setup_controller.rb:120: warning: string literal in condition
Loading development environment (Rails 3.1.0)
irb(main):001:0&gt; RetsMap
=&gt; RetsMap
irb(main):002:0&gt; RetsMap::Base
=&gt; RetsMap::Base
irb(main):003:0&gt; reload!
Reloading...
=&gt; true
irb(main):004:0&gt; RetsMap
=&gt; RetsMap
irb(main):005:0&gt; RetsMap::Base
=&gt; RetsMap::Base
irb(main):006:0&gt; reload!
Reloading...
=&gt; true
irb(main):007:0&gt; RetsMap
=&gt; RetsMap
irb(main):008:0&gt; RetsMap::Base
LoadError: Expected /Users/jason/Sites/rj4/rails/app/models/rets_map/base.rb to define RetsMap::Base
	from /opt/local/lib/ruby/gems/1.8/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:490:in `load_missing_constant'
	from /opt/local/lib/ruby/gems/1.8/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:181:in `const_missing'
	from /opt/local/lib/ruby/gems/1.8/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:179:in `each'
	from /opt/local/lib/ruby/gems/1.8/gems/activesupport-3.1.0/lib/active_support/dependencies.rb:179:in `const_missing'
	from (irb):8</pre>
<p>For some reason after I would tell the console to reload the models, I got an error that the file didn&#8217;t define RetsMap::Base&#8230;.but it did damnit!!</p>
<p>The error was regarding ActiveSupport, so I tried to reinstall the Rails gem and ActiveSupport gem, but this didn&#8217;t help.</p>
<p>The solution I had found was to upgrade to Rails 3.1.1. After doing this, the error no longer occurred, even after I had reloaded the models.</p>
<p>Ooh, also, I didn&#8217;t mention. Previously I was using the following command in /config/application.rb:</p>
<pre class="brush:rails">config.autoload_paths += Dir["#{config.root}/app/models/**/"]</pre>
<p>As part of my troubleshooting I figured that by default Rails will try to load models from subdirectories if they conform to the proper directory and file naming required for namespaced models. When you add models to the autoload paths configuration, I think it expects that those conventions don&#8217;t apply&#8230;or maybe this just causes problems. I commented this line out and simply added each subdirectory that contained non-namespaced models.</p>
<pre class="brush:rails">config.autoload_paths += %W(#{config.root}/app/models/email/)
config.autoload_paths += %W(#{config.root}/app/models/sub/)
config.autoload_paths += %W(#{config.root}/app/models/upload/)</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.redconfetti.com/2011/12/resolving-issues-with-namespaced-models-in-rails-3-1-0/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Paperclip error with non-image file</title>
		<link>http://www.redconfetti.com/2011/12/paperclip-error-with-non-image-file/</link>
		<comments>http://www.redconfetti.com/2011/12/paperclip-error-with-non-image-file/#comments</comments>
		<pubDate>Mon, 05 Dec 2011 20:43:25 +0000</pubDate>
		<dc:creator>redconfetti</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[identify]]></category>
		<category><![CDATA[imagemagick]]></category>
		<category><![CDATA[linkedin]]></category>
		<category><![CDATA[non-image]]></category>
		<category><![CDATA[paperclip]]></category>

		<guid isPermaLink="false">http://www.redconfetti.com/?p=924</guid>
		<description><![CDATA[Recently I updated to Rails 3.1 from 2.3.8 for a project I&#8217;m working on. Paperclip version 2.4.5 was working perfectly well for me locally on my Mac OS X 10.7.2 laptop, with ImageMagick version 6.7.3-1. We had just launched the upgraded Rails 3.1 application to our production server, which went smoothly, but upon my checklist of...]]></description>
			<content:encoded><![CDATA[<p>Recently I updated to Rails 3.1 from 2.3.8 for a project I&#8217;m working on. Paperclip version 2.4.5 was working perfectly well for me locally on my Mac OS X 10.7.2 laptop, with ImageMagick version 6.7.3-1.</p>
<p>We had just launched the upgraded Rails 3.1 application to our production server, which went smoothly, but upon my checklist of pages to test (we don&#8217;t have test suite in use yet) I noticed that the file upload was failing. Further investigation showed that the object using paperclip was failing to save:</p>
<pre class="brush:shell">upload.errors.inspect: 

#["/tmp/stream20111205-28441-10oj2ck-0.csv is not recognized by the 'identify' command.", "/tmp/stream20111205-28441-10oj2ck-0.csv is not recognized by the 'identify' command."]}&gt;, @base=#&gt;</pre>
<p>Further investigation helped me identify this &#8216;identify&#8217; command as an executable provided by ImageMagick. I ran this command on the temporary file which was located in /tmp, and I got an error such as the one that follows on both my local machine and in production. The odd thing was that the file upload worked locally, but was failing remotely.</p>
<pre class="brush:shell">$ identify test-import20111205-1909-1xsbr19-0.csv 

identify: no decode delegate for this image format `test-import20111205-1909-1xsbr19-0.csv' @ error/constitute.c/ReadImage/532.</pre>
<p>This didn&#8217;t make sense. I was uploading a CSV file, not an image. I wasn&#8217;t even using the &#8216;:styles&#8217; hash value in my model with the &#8216;has_attached_file&#8217; expression. Why was it checking to see what type of image the file is?!?!</p>
<p>I tried to upgrade and reinstall ImageMagick on the production server, but this had no effect. This made me suspect that paperclip was the cause of the issue. I also created an initalizer for paperclip under /config/initalizers/paperclip.rb pointing out the image_magick_path, which I had seen resolve other issues with &#8216;identify&#8217; errors.</p>
<pre class="brush:rails">if Rails.env == 'production'
  Paperclip.options[:image_magick_path] = "/usr/bin/"
end</pre>
<p>This didn&#8217;t help at all.</p>
<p>I tried to reconfigure the application to use Paperclip version 2.4.4 and 2.4.3, but that didn&#8217;t resolve the issue.</p>
<p>Finally I updated my Gemfile to use the latest Github version of Paperclip. I deployed this update, tested, and finally the issue was resolved.</p>
<pre class="brush:rails">gem 'paperclip', "~&gt; 2.4.5", :git =&gt; 'git://github.com/thoughtbot/paperclip.git'</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.redconfetti.com/2011/12/paperclip-error-with-non-image-file/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Issues with RVM</title>
		<link>http://www.redconfetti.com/2011/11/issues-with-rvm/</link>
		<comments>http://www.redconfetti.com/2011/11/issues-with-rvm/#comments</comments>
		<pubDate>Mon, 14 Nov 2011 00:11:04 +0000</pubDate>
		<dc:creator>redconfetti</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[linkedin]]></category>
		<category><![CDATA[os x lion]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[rvm]]></category>

		<guid isPermaLink="false">http://www.redconfetti.com/?p=912</guid>
		<description><![CDATA[I recently decided to check out BrowserCMS, to evaluate how it work and decide to use it&#8230;or RefineryCMS. I didn&#8217;t expect that BrowserCMS would require Ruby 1.9.2. I&#8217;ve been running with Ruby 1.8.6 or 1.8.7 for quite a while now without any issues. It looks like it was time that I install RVM: Ruby Version Manager....]]></description>
			<content:encoded><![CDATA[<p>I recently decided to check out <a title="BrowserCMS - BrowserCMS - Open Source, Ruby on Rails CMS" href="http://www.browsercms.org/" target="_blank">BrowserCMS</a>, to evaluate how it work and decide to use it&#8230;or <a title="Refinery CMS - a CMS that supports Rails 3" href="http://www.refinerycms.com/" target="_blank">RefineryCMS</a>. I didn&#8217;t expect that BrowserCMS would require Ruby 1.9.2. I&#8217;ve been running with Ruby 1.8.6 or 1.8.7 for quite a while now without any issues. It looks like it was time that I install <a title="RVM: Ruby Version Manager" href="https://rvm.beginrescueend.com/" target="_blank">RVM: Ruby Version Manager</a>.</p>
<p>I read through the documentation, followed the instructions to ensure that prerequisite software was installed. I specifically made sure that certain commands that it stated would be needed were all in my command line path under /opt/local, where the MacPorts all install. I try to maintain a command line environment that&#8217;s almost entirely dependent on MacPorts. Prior to ensuring this I ran into issues where software I&#8217;ve tried to install was using one utility or library provided natively by Mac OS X, while using some other utility or library I&#8217;ve installed separately, conflict due to differences and stop certain software from building properly upon install.</p>
<p>I also took note that since I&#8217;m using MacPorts, I should <a href="https://rvm.beginrescueend.com/integration/macports/" target="_blank">configure my $HOME/.rvmrc</a> file so that RVM uses my MacPort libraries when building gems.</p>
<h2>Installation of Ruby</h2>
<p>The installation of the RVM software itself went smoothly. I felt good knowing that I was about to learn how RVM works and it will become another tool that I gladly assign to my arsenal of software to be used in the future (and add to my resume).</p>
<p>Then I ran into an issue with something in &#8216;readline.c&#8217; when I attempted to install Ruby 1.8.7.</p>
<pre class="brush:rails">jason@imac ~$ rvm install 1.8.7 --with-openssl-dir=/opt/local

Installing Ruby from source to: /Users/jason/.rvm/rubies/ruby-1.8.7-p352, this may take a while depending on your cpu(s)...

ruby-1.8.7-p352 - #fetching
ruby-1.8.7-p352 - #extracting ruby-1.8.7-p352 to /Users/jason/.rvm/src/ruby-1.8.7-p352
ruby-1.8.7-p352 - #extracted to /Users/jason/.rvm/src/ruby-1.8.7-p352
Applying patch 'stdout-rouge-fix' (located at /Users/jason/.rvm/patches/ruby/1.8.7/stdout-rouge-fix.patch)
ruby-1.8.7-p352 - #configuring
ruby-1.8.7-p352 - #compiling
ERROR: Error running 'make ', please read /Users/jason/.rvm/log/ruby-1.8.7-p352/make.log
ERROR: There has been an error while running make. Halting the installation.

jason@imac ~$ tail -10 /Users/jason/.rvm/log/ruby-1.8.7-p352/make.log
.
.
.
compiling readline
/usr/bin/gcc-4.2 -I. -I../.. -I../../. -I../.././ext/readline -DHAVE_READLINE_READLINE_H -DHAVE_READLINE_HISTORY_H -DHAVE_RL_FILENAME_COMPLETION_FUNCTION -DHAVE_RL_COMPLETION_MATCHES -DHAVE_RL_DEPREP_TERM_FUNCTION -DHAVE_RL_COMPLETION_APPEND_CHARACTER -DHAVE_RL_BASIC_WORD_BREAK_CHARACTERS -DHAVE_RL_COMPLETER_WORD_BREAK_CHARACTERS -DHAVE_RL_BASIC_QUOTE_CHARACTERS -DHAVE_RL_COMPLETER_QUOTE_CHARACTERS -DHAVE_RL_FILENAME_QUOTE_CHARACTERS -DHAVE_RL_ATTEMPTED_COMPLETION_OVER -DHAVE_RL_LIBRARY_VERSION -DHAVE_RL_EVENT_HOOK -DHAVE_RL_CLEANUP_AFTER_SIGNAL -DHAVE_REPLACE_HISTORY_ENTRY -DHAVE_REMOVE_HISTORY -I/opt/local/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE  -I/opt/local/include -fno-common -arch x86_64 -g -Os -pipe -no-cpp-precomp  -fno-common -pipe -fno-common   -c readline.c
readline.c: In function ‘username_completion_proc_call’:
readline.c:730: error: ‘username_completion_function’ undeclared (first use in this function)
readline.c:730: error: (Each undeclared identifier is reported only once
readline.c:730: error: for each function it appears in.)
make[1]: *** [readline.o] Error 1
make: *** [all] Error 1</pre>
<p>I tried to install &#8216;readline&#8217; using MacPorts because I read online that this was a common issue with Mac OS X users under Snow Leopard. This didn&#8217;t help, and in fact I got an error after trying to install readline from source as recommended in the forum post I found regarding the subject.</p>
<p>After further search, I realized that the RVM documentation (which is pretty good I must say) has <a title="RVM install ruby readline" href="https://rvm.beginrescueend.com/packages/readline/" target="_blank">a page devoted to this issue</a>.</p>
<h2>Issue Installing Custom Gems</h2>
<p>Later I had installed Ruby 1.9.2 as well, because I needed it for BrowserCMS. I was trying to install gems for Ruby, but each time it would give me the &#8216;Invalid gemspec &#8230; invalid date format in specification&#8217; error that I recall from a time when I was using a newer version of RubyGems than the gems I had installed were made for, like:</p>
<pre class="brush:rails">Invalid gemspec in [/opt/local/lib/ruby/gems/1.8/specifications/paperclip-2.4.3.gemspec]: invalid date format in specification: "2011-10-05 00:00:00.000000000Z"</pre>
<p>I made sure I was running under Ruby 1.9.2, and that the version of RubyGems would be the one associated with Ruby version 1.9.2, and then upgraded it to version</p>
<pre class="brush:rails">imac:Sites jason$ rvm 1.9.2
imac:Sites jason$ rvm gemdir
/Users/jason/.rvm/gems/ruby-1.9.2-p290
imac:Sites jason$ rvm rubygems current
Removing old Rubygems files...
Installing rubygems-1.8.10 for ruby-1.9.2-p290 ...
Installation of rubygems completed successfully.</pre>
<p>I tried to check or change which version of gem I was using, and it would tell me it&#8217;s using one installed under RVM, but still it would give errors as if it was using an older version of RubyGems.</p>
<pre class="brush:rails">imac:Sites jason$ which gem
/Users/jason/.rvm/rubies/ruby-1.9.2-p290/bin/gem

imac:Sites jason$ sudo gem install browsercms

Invalid gemspec in [/opt/local/lib/ruby/gems/1.8/specifications/capistrano-2.9.0.gemspec]: invalid date format in specification: "2011-09-24 00:00:00.000000000Z"</pre>
<p>I then found out that I had a .gemrc file setup that was loading in my command line environment, and thus interfering with the dependency loading which RVM provides.</p>
<pre class="brush:rails">imac:Sites jason$ cd ~
imac:~ jason$ cat .gemrc
gemhome: /opt/local/lib/ruby/gems/1.8
gempath:
 - /opt/local/lib/ruby/gems/1.8
 - /Users/jason/gems
imac:~ jason$</pre>
<p>I simply renamed this file as .gemrc.bak and this resolved the issue so that gems I install under Ruby v1.9.2 will use the RubyGem version associated with the Ruby 1.9.2 installation.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.redconfetti.com/2011/11/issues-with-rvm/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Redirect_to not working</title>
		<link>http://www.redconfetti.com/2011/09/redirect_to-not-working/</link>
		<comments>http://www.redconfetti.com/2011/09/redirect_to-not-working/#comments</comments>
		<pubDate>Tue, 27 Sep 2011 20:37:59 +0000</pubDate>
		<dc:creator>redconfetti</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[http post]]></category>
		<category><![CDATA[linkedin]]></category>

		<guid isPermaLink="false">http://www.redconfetti.com/?p=896</guid>
		<description><![CDATA[I was just working on a Ruby on Rails controller method that receives information from the previous form via HTTP POST. I coded it so that if certain form variables weren&#8217;t present it would set a flash message and redirect to the form page. I tried and tried and still the redirect wasn&#8217;t working. I...]]></description>
			<content:encoded><![CDATA[<p>I was just working on a Ruby on Rails controller method that receives information from the previous form via HTTP POST. I coded it so that if certain form variables weren&#8217;t present it would set a flash message and redirect to the form page. I tried and tried and still the redirect wasn&#8217;t working. I reset my web server, and even restarted my computer, but stil this didn&#8217;t resolve the issue.</p>
<p>I then realized that perhaps redirects aren&#8217;t possible with HTTP POST&#8217;s, only GET requests. I ended up just creating a generic view for displaying errors, and will render that view and then &#8216;return FALSE&#8217; inside of the if statement when an error is detected.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.redconfetti.com/2011/09/redirect_to-not-working/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Advanced Use of Will_Paginate</title>
		<link>http://www.redconfetti.com/2011/09/advanced-use-of-will_paginate/</link>
		<comments>http://www.redconfetti.com/2011/09/advanced-use-of-will_paginate/#comments</comments>
		<pubDate>Fri, 23 Sep 2011 22:08:56 +0000</pubDate>
		<dc:creator>redconfetti</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[linkedin]]></category>
		<category><![CDATA[pagination]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[will_paginate]]></category>

		<guid isPermaLink="false">http://www.redconfetti.com/?p=859</guid>
		<description><![CDATA[I&#8217;m building an index of contacts, displayed with paginated links provided by will_paginate. The wiki for this plugin advises you on how to do setup your controller method, and what to put in the view to obtain a simple set of links, such as: # /app/controllers/contact_controller.rb def index @contacts = Contact.paginate :page =&#62; params[:page], :per_page...]]></description>
			<content:encoded><![CDATA[<p>I&#8217;m building an index of contacts, displayed with paginated links provided by <a href="https://github.com/mislav/will_paginate/wiki" target="_blank">will_paginate</a>.</p>
<p>The wiki for this plugin advises you on how to do setup your controller method, and what to put in the view to obtain a simple set of links, such as:</p>
<pre class="brush:rails"># /app/controllers/contact_controller.rb
def index
  @contacts = Contact.paginate :page =&gt; params[:page], :per_page =&gt; 10, :order =&gt; 'created_at DESC'
end

# /app/views/contact/index.html.erb
&lt;%= will_paginate @contacts %&gt;</pre>
<p>What I&#8217;m not finding however are more advanced methods of using the will_paginate plugin. Here are a few things I&#8217;ve found.</p>
<h3>Links at top and bottom of paginated section</h3>
<p>You can add the paginated links to the top and bottom of your paginated section using this syntax:</p>
<pre class="brush:rails">&lt;% paginated_section @contacts do %&gt;
	&lt;table id="contacts"&gt;
		&lt;%= render(:partial =&gt; "contact_row", :collection =&gt; @contacts) %&gt;
	&lt;/table&gt;
&lt;% end %&gt;</pre>
<h3>Display Page Entries Info</h3>
<p>You can display text on your page such as &#8216;Displaying contacts <strong>11 - 12</strong> of <strong>12</strong> in total&#8217; by using the following view helper.</p>
<pre class="brush:rails">&lt;%= page_entries_info @contacts %&gt;</pre>
<h3>Current and Total Page Number</h3>
<p>If you want to display the total number of pages in your own way, you can do this by using the &#8216;total_pages&#8217; method of the paginated collection.</p>
<pre class="brush:rails">&lt;p&gt;You are viewing page &lt;%= @contacts.current_page %&gt;
of &lt;%= @contacts.total_pages %&gt;&lt;/p&gt;</pre>
<p>&nbsp;</p>
]]></content:encoded>
			<wfw:commentRss>http://www.redconfetti.com/2011/09/advanced-use-of-will_paginate/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruby on Rails session &#8211; Access from PHP</title>
		<link>http://www.redconfetti.com/2010/12/ruby-on-rails-session-access-from-php/</link>
		<comments>http://www.redconfetti.com/2010/12/ruby-on-rails-session-access-from-php/#comments</comments>
		<pubDate>Tue, 14 Dec 2010 04:25:37 +0000</pubDate>
		<dc:creator>redconfetti</dc:creator>
				<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[linkedin]]></category>

		<guid isPermaLink="false">http://www.redconfetti.com/?p=653</guid>
		<description><![CDATA[If you need to access a Ruby on Rails session from a PHP application running under the same domain, you can do this by splitting the string in the cookie by the &#8216;&#8211;&#8217;. Thanks to Frederick Cheung for pointing this out. Here is coding I added to my PHP script which was running from a...]]></description>
			<content:encoded><![CDATA[<p>If you need to access a Ruby on Rails session from a PHP application running under the same domain, you can do this by splitting the string in the cookie by the &#8216;&#8211;&#8217;. Thanks to Frederick Cheung for <a href="http://www.ruby-forum.com/topic/158813">pointing this out</a>.</p>
<p>Here is coding I added to my PHP script which was running from a path under the same domain. Unfortunately the data returned is in Marshal format, and there isn&#8217;t a Marshal.load function for PHP to get the values easily.</p>
<pre class="brush:php">
$raw_session_string = $_COOKIE['_app_session'];
$data_split = explode ('--' , $raw_session_string);
$encoded_session = $data_split[0];
$marshal_data = base64_decode($encoded_session);
echo "&lt;pre&gt;marshal_data:". print_r($marshal_data,1) ."&lt;/pre&gt;\n";
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.redconfetti.com/2010/12/ruby-on-rails-session-access-from-php/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

