<?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>Marco Tapia</title>
	<atom:link href="http://firebait.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://firebait.com</link>
	<description>my way to blog about development</description>
	<lastBuildDate>Mon, 19 Sep 2011 17:06:41 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.2.1</generator>
		<item>
		<title>Edit on the Fly with Simply_Edit</title>
		<link>http://firebait.com/edit-on-the-fly/</link>
		<comments>http://firebait.com/edit-on-the-fly/#comments</comments>
		<pubDate>Mon, 19 Sep 2011 17:05:45 +0000</pubDate>
		<dc:creator>firebait</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://firebait.com/?p=131</guid>
		<description><![CDATA[Hello all, I just uploaded a gem that lets you updated fields on the fly, is called simply_edit. Is the sister gem of simply_load that you can find on rubygems and github. Simply edit transforms labels into editable fields like &#8230; <a href="http://firebait.com/edit-on-the-fly/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Hello all,</p>
<p>I just uploaded a gem that lets you updated fields on the fly, is called simply_edit. Is the sister gem of simply_load that you can find on <a href="https://rubygems.org/gems/simply_load">rubygems</a> and <a href="https://github.com/firebait/simply_load">github</a>.</p>
<p>Simply edit transforms labels into editable fields like textfield, textareas and datefield(using jQuery date picker).</p>
<p>Why did I make a gem out of this little thing? I felt it was a waste of time to got to a form if you only needed to update a title, content or a date.</p>
<p>Here is the gem at <a href="https://rubygems.org/gems/simply_edit">rubygems</a> and <a href=https://github.com/firebait/simply_edit">github</a>.</p>
<p>Anyway, I hope you guys like it and comment about it.</p>
<p><script type="text/javascript"><!--
google_ad_client = "ca-pub-4771379912678290";
/* firebait.com-468x60-Banner */
google_ad_slot = "9933565687";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://firebait.com/edit-on-the-fly/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Gem Called &#8220;simply_load&#8221;</title>
		<link>http://firebait.com/a-gem-called-simply_load/</link>
		<comments>http://firebait.com/a-gem-called-simply_load/#comments</comments>
		<pubDate>Thu, 14 Jul 2011 15:44:10 +0000</pubDate>
		<dc:creator>firebait</dc:creator>
				<category><![CDATA[Gem]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>
		<category><![CDATA[Simply_load]]></category>

		<guid isPermaLink="false">http://firebait.com/?p=111</guid>
		<description><![CDATA[Hello all, Just yesterday, I released a gem called &#8220;simply_load&#8221;. Simply load is really just a short way to write a JQuery load method to populate a page. Why did I make a gem out of this little thing? I &#8230; <a href="http://firebait.com/a-gem-called-simply_load/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Hello all,</p>
<p>Just yesterday, I released a gem called &#8220;simply_load&#8221;.</p>
<p>Simply load is really just a short way to write a JQuery load method to populate a page.</p>
<p>Why did I make a gem out of this little thing? I just thought it was fun to load pieces of html at random or have a little form widget without having to actually instantiate the object on a completely unrelated controller method.</p>
<p>Here is the gem at <a href="https://rubygems.org/gems/simply_load">rubygems</a> and <a href="https://github.com/firebait/simply_load">github</a>.</p>
<p>Anyway, I hope you guys like it and comment about it.</p>
<p><script type="text/javascript"><!--
google_ad_client = "ca-pub-4771379912678290";
/* firebait.com-468x60-Banner */
google_ad_slot = "9933565687";
google_ad_width = 468;
google_ad_height = 60;
//-->
</script>
<script type="text/javascript"
src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
</script></p>
]]></content:encoded>
			<wfw:commentRss>http://firebait.com/a-gem-called-simply_load/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Do not create methods from table records with Ruby Metaprogramming</title>
		<link>http://firebait.com/do-not-create-methods-from-table-records-with-ruby-metaprogramming/</link>
		<comments>http://firebait.com/do-not-create-methods-from-table-records-with-ruby-metaprogramming/#comments</comments>
		<pubDate>Thu, 30 Jun 2011 02:59:13 +0000</pubDate>
		<dc:creator>firebait</dc:creator>
				<category><![CDATA[metaprogramming]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://firebait.com/?p=76</guid>
		<description><![CDATA[I recently got the opportunity to integrate the Devise gem with Cancan for authentication and authorization. These gems are a real time saver and one really good thing about these is the ability to customize them especially Cancan. Cancan doesn&#8217;t &#8230; <a href="http://firebait.com/do-not-create-methods-from-table-records-with-ruby-metaprogramming/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>I recently got the opportunity to integrate the <a href="https://github.com/plataformatec/devise">Devise</a> gem with <a href="http://rubygems.org/gems/cancan">Cancan</a> for authentication and authorization.<br />
These gems are a real time saver and one really good thing about these is the ability to customize them especially Cancan. Cancan doesn&#8217;t enforce a model on you or a data structure for it to work, you can define the role table as you will and plug it in to your app.</p>
<p>But this blog is not intended to be a blog about authorization and authentication is more about using metaprogramming as a tool for generating methods from table records.<br />
In my particular case I used a Roles table with a name field, pretty standard. My first instinct was to loop thru the records in the Roles table and generate a method called &#8220;is_role_name?&#8221;. This was my implementation.</p>
<pre name="code" class="ruby">
Role.all.each do |role|
   define_method("is_#{role.name.downcase}?") do
      !roles.find_by_name(role).nil?
   end
end
</pre>
<p>This worked really well as I could query a user and just ask for <code>user.is_admin?</code> and that would be it. The problem happened when I wanted to test it, because the database get&#8217;s deleted, all of the seed data for the default roles get deleted as well. If I tried to create them after the fact, the User model was already loaded so the methods never get created. Even worst if I went and drop the database and tried to create it, it would blow up saying that there is no Roles table when it&#8217;s loading the User model (there is a clever way around this, just put this piece of code after the <code>Roles.all.each loop</code> and the methods won&#8217;t get created if there is no Roles table: <code>if ActiveRecord::Base.connection.tables.include?('roles')</code>. So, no good.</p>
<p>I had to go back to the traditional way of querying roles and use <code>user.has_role?(admin)</code> which if fine if you want to keep thing simple. But my goal was to call the roles using the role name inside the method so <code>method_missing</code> to the rescue.</p>
<pre name="code" class="ruby">
  def has_role?(role)
    !roles.find_by_name(role).nil?
  end

  def method_missing(method, *args)
    return has_role?($1.to_s, *args) if method =~ /^is_+(.*)\?/
    super
  end
</pre>
<p>This way you can still user the format <code>user.is_admin?</code> to call your roles and not have the issue of creating methods with seed data or table records.</p>
<p>Hope this helps.</p>
]]></content:encoded>
			<wfw:commentRss>http://firebait.com/do-not-create-methods-from-table-records-with-ruby-metaprogramming/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Working with google maps markers</title>
		<link>http://firebait.com/working-with-google-maps-markers/</link>
		<comments>http://firebait.com/working-with-google-maps-markers/#comments</comments>
		<pubDate>Thu, 11 Nov 2010 17:10:33 +0000</pubDate>
		<dc:creator>firebait</dc:creator>
				<category><![CDATA[Google Maps]]></category>

		<guid isPermaLink="false">http://firebait.com/?p=70</guid>
		<description><![CDATA[Hello all, I just wanted to share Mark Ridey&#8217;s blog post on &#8220;Using MarkerImage in Maps Javascript API v3&#8243; as it helped me work with google maps markers on my latest project. Later!]]></description>
			<content:encoded><![CDATA[<p>Hello all,</p>
<p>I just wanted to share Mark Ridey&#8217;s blog post on <a href="http://blog.mridey.com/2010/03/using-markerimage-in-maps-javascript.html">&#8220;Using MarkerImage in Maps Javascript API v3&#8243;</a> as it helped me work with google maps markers on my latest project.<br />
Later!</p>
]]></content:encoded>
			<wfw:commentRss>http://firebait.com/working-with-google-maps-markers/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Prototype Ajax.Response with Rails Json</title>
		<link>http://firebait.com/prototype-ajax-response-with-rails-json/</link>
		<comments>http://firebait.com/prototype-ajax-response-with-rails-json/#comments</comments>
		<pubDate>Wed, 15 Sep 2010 02:50:17 +0000</pubDate>
		<dc:creator>firebait</dc:creator>
				<category><![CDATA[Javascript]]></category>
		<category><![CDATA[Prototype]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://firebait.com/?p=56</guid>
		<description><![CDATA[Json is just way faster than updating partials with Rails, so why didn&#8217;t I use it before? Well, basically I was just new to the Rails thing and it&#8217;s just easy to update with a partial. But I was presented &#8230; <a href="http://firebait.com/prototype-ajax-response-with-rails-json/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Json is just way faster than updating partials with Rails, so why didn&#8217;t I use it before?<br />
Well, basically I was just new to the Rails thing and it&#8217;s just easy to update with a partial. But I was presented with a choice recently, I had to update a resource intensive Google Map part of the page with an textfield keyup event.<br />
At first glance it was cake, just observe the keyup event and send an Ajax call to update the partial. That got really slow since I had to create the map object everytime.<br />
The other answer that you might be thinking is why didn&#8217;t he just update it with the page element in rails from the controller.<br />
Is not that simple, I wanted to write this as separated from the backend as possible as I want to share this as an API in the future, so having view updates in the backend or in a partial was not going to cut it.<br />
The task was simple, it was just moving the map location and setting a marker, it&#8217;s literally two lines of code so why not just pass a Json response from the rails backend and update the map.<br />
Seems easy until I found that I couldn&#8217;t do the following:</p>
<pre name="code" class="javascript">
				new Ajax.Request(url, {
					parameters: {query: this.getValue()},
					method: 'get',
					onSuccess: function(transport,){
						var response = transport.responseText;
						alert(response.somevalue);
					}
				});
</pre>
<p>I will always get the somevalue undefined. I also found that it was because even though I would send the response as json, for some reason it was in json format but not an actual json object.</p>
<p>This was my rendering line:</p>
<pre name="code" class="ruby">
     render :json => "{somevalue:#{my_value.to_json}}"
</pre>
<p>I found that I only needed to change this line:</p>
<pre name="code" class="javascript">
     var response = transport.responseText.evalJSON();
</pre>
<p>And that was how I got my Json working after an hour of googling. I found it on the prototype api documentation.<br />
Read the manual kids!!!<br />
Firebait</p>
]]></content:encoded>
			<wfw:commentRss>http://firebait.com/prototype-ajax-response-with-rails-json/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Facebook Wishlist Application Tutorial</title>
		<link>http://firebait.com/facebook-wishlist-application-tutorial/</link>
		<comments>http://firebait.com/facebook-wishlist-application-tutorial/#comments</comments>
		<pubDate>Mon, 13 Sep 2010 04:39:33 +0000</pubDate>
		<dc:creator>firebait</dc:creator>
				<category><![CDATA[Facebook]]></category>
		<category><![CDATA[Wish List]]></category>

		<guid isPermaLink="false">http://firebait.com/?p=32</guid>
		<description><![CDATA[Hello all, I just wanted to share that after some suggestions I decided to record a little tutorial on how to use the Facebook Wishlist application. Check it out and let me know what you think. Hope you all enjoy &#8230; <a href="http://firebait.com/facebook-wishlist-application-tutorial/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Hello all,</p>
<p>I just wanted to share that after some suggestions I decided to record a little tutorial on how to use the Facebook Wishlist application.<br />
Check it out and let me know what you think.</p>
<p><object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="425" height="344" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab#version=6,0,40,0"><param name="allowFullScreen" value="true" /><param name="src" value="http://www.youtube.com/v/hQkxdFZ3DBU&amp;hl=en&amp;fs=1" /><param name="allowfullscreen" value="true" /><embed type="application/x-shockwave-flash" width="425" height="344" src="http://www.youtube.com/v/hQkxdFZ3DBU&amp;hl=en&amp;fs=1" allowfullscreen="true"></embed></object></p>
<p>Hope you all enjoy this little tutorial.</p>
<p>Firebait</p>
]]></content:encoded>
			<wfw:commentRss>http://firebait.com/facebook-wishlist-application-tutorial/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Facebooker on a Tab</title>
		<link>http://firebait.com/facebooker-on-a-tab/</link>
		<comments>http://firebait.com/facebooker-on-a-tab/#comments</comments>
		<pubDate>Tue, 07 Sep 2010 14:30:58 +0000</pubDate>
		<dc:creator>firebait</dc:creator>
				<category><![CDATA[Facebook]]></category>
		<category><![CDATA[Facebooker]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://firebait.com/?p=18</guid>
		<description><![CDATA[Hello all, As you know I&#8217;ve been playing with facebooker for the past few days and I want my app to work on both canvas and tab. This is the first thing you have to do in order to get &#8230; <a href="http://firebait.com/facebooker-on-a-tab/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Hello all,</p>
<p>As you know I&#8217;ve been playing with facebooker for the past few days and I want my app to work on both canvas and tab.<br />
This is the first thing you have to do in order to get your app on a tab.<br />
Apply these before filters:</p>
<pre name="code" class="ruby">
      before_filter :check_authentication
      before_filter :check_installation
      before_filter :get_user

      private

      def check_authentication
        ensure_authenticated_to_facebook unless request_is_facebook_tab?
      end

      def check_installation
        ensure_application_is_installed_by_facebook_user unless request_is_facebook_tab?
      end

      def get_user
        if request_is_facebook_tab?
          @facebook_user = Facebooker::User.new(params['fb_sig_profile_id'],Facebooker::Session.create)
        else
          @facebook_user = facebook_session.user
        end
        @user = User.find_or_create_by_uid(@facebook_user.uid)
      end
</pre>
<p>As you can see I had to manually retrieve the fb_sig_profile_id from the request in order to make this work. If someone found what is the equivalent in facebooker I will really appreciate it.</p>
<p>Firebait</p>
]]></content:encoded>
			<wfw:commentRss>http://firebait.com/facebooker-on-a-tab/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Facebooker: Filter chain halted as [:ensure_authenticated_to_facebook]</title>
		<link>http://firebait.com/facebooker-filter-chain-halted-as-ensure_authenticated_to_facebook/</link>
		<comments>http://firebait.com/facebooker-filter-chain-halted-as-ensure_authenticated_to_facebook/#comments</comments>
		<pubDate>Tue, 07 Sep 2010 14:29:20 +0000</pubDate>
		<dc:creator>firebait</dc:creator>
				<category><![CDATA[Facebook]]></category>
		<category><![CDATA[Facebooker]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://firebait.com/?p=9</guid>
		<description><![CDATA[Hello everyone, this is my first post, and I will write a very short one. I&#8217;ve been playing with the facebooker plugin for Rails and I followed this tutorial and got it up and running pretty fast. The only issue &#8230; <a href="http://firebait.com/facebooker-filter-chain-halted-as-ensure_authenticated_to_facebook/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>Hello everyone, this is my first post, and I will write a very short one. I&#8217;ve been playing with the facebooker plugin for Rails and I followed this tutorial and got it up and running pretty fast. The only issue I had was I kept getting this error:</p>
<pre name="code" class="ruby">
Filter chain halted as [:ensure_authenticated_to_facebook] rendered_or_redirected.
</pre>
<p>When I used this before_filters:</p>
<pre name="code" class="ruby">
ensure_authenticated_to_facebook
ensure_application_is_installed_by_facebook_user
</pre>
<p>I spend a day running around just to find that I needed to add this piece of code to my application_controller file or configure your &#8220;Post-Authorize Redirect&#8221; with out trailing &#8220;/&#8221;.</p>
<pre name="code" class="ruby">
def after_facebook_login_url
     request.request_uri
end
</pre>
<p>Hope this helps all of you that are trying to write rails apps for facebook<br />
Firebait out!</p>
]]></content:encoded>
			<wfw:commentRss>http://firebait.com/facebooker-filter-chain-halted-as-ensure_authenticated_to_facebook/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Bienvenidos a mi Blog</title>
		<link>http://firebait.com/bienvenidos-a-mi-blog/</link>
		<comments>http://firebait.com/bienvenidos-a-mi-blog/#comments</comments>
		<pubDate>Wed, 03 Mar 2010 18:49:36 +0000</pubDate>
		<dc:creator>firebait</dc:creator>
				<category><![CDATA[Facebook]]></category>
		<category><![CDATA[Ruby]]></category>
		<category><![CDATA[Ruby on Rails]]></category>

		<guid isPermaLink="false">http://tagengineeringenvironments.com/blog/?p=1</guid>
		<description><![CDATA[This is my First post. Just to let you know that I&#8217;m going to start blogging about the different stuff I&#8217;m coding so expect some updates soon. I&#8217;m currently working on a Facebook app so my first posts are about &#8230; <a href="http://firebait.com/bienvenidos-a-mi-blog/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
			<content:encoded><![CDATA[<p>This is my First post. Just to let you know that I&#8217;m going to start blogging about the different stuff I&#8217;m coding so expect some updates soon.<br />
I&#8217;m currently working on a Facebook app so my first posts are about Facebooker, a really cool framework for developing Facebook apps with Ruby on Rails.<br />
Besides that, I really like writing CMS systems, and I hope to sometime have the time to write and open source version.<br />
By for now.<br />
Firebait!</p>
]]></content:encoded>
			<wfw:commentRss>http://firebait.com/bienvenidos-a-mi-blog/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

