Jekyll2020-10-01T06:40:02+00:00https://millarian.com/feed.xmlMillarianMusings of a startup junkie and Ruby on Rails nerd.Curtis MillerRails 6, Webpacker, and the Cocoon gem2020-06-30T08:00:00+00:002020-06-30T08:00:00+00:00https://millarian.com/rails/adding-the-cocoon-gem-to-rails-6-with-webpacker<p>
If you're not familiar with the <a rel="nofollow" href="https://github.com/nathanvda/cocoon">Cocoon gem</a>, it's an awesome little gem to help with easily handling nested forms. We've used it with great success on many of our Rails projects.
</p>
<p>
The docs currently say that it supports Rails 3, 4, and 5, but there's no mention of Rails 6, or Webpacker. Having started a new Rails 6 project recently, this was unfortunate. Luckily, it was pretty easy to get Cocoon installed and working.
<p>
<p>
Buried in an <a rel="nofollow" href="https://github.com/nathanvda/cocoon/issues/555#issuecomment-640256856">open issue</a> is some information on how to get set up. Here's what we did:
</p>
<ol>
<li>
You will need the gem, so add
<figure class="highlight"><pre><code class="language-ruby" data-lang="ruby"><span class="n">gem</span> <span class="s1">'cocoon'</span></code></pre></figure>
to your Gemfile, then bundle as normal.
</li>
<li>
You will also need the JavaScript package, so from the root of your Rails app, run
<figure class="highlight"><pre><code class="language-shell" data-lang="shell">yarn add github:nathanvda/cocoon#c24ba53</code></pre></figure>
If you check your <code>package.json</code> you should see Cocoon is now listed.
</li>
<li>
Then, add Cocoon to your list of requires in the <code>app/javascript/packs/application.js</code> file, like so:
<figure class="highlight"><pre><code class="language-javascript" data-lang="javascript"><span class="nx">require</span><span class="p">(</span><span class="dl">"</span><span class="s2">cocoon</span><span class="dl">"</span><span class="p">)</span></code></pre></figure>
</li>
</ol>
<p>
One last note, Cocoon currently requires jQuery, so be sure that's installed as well. If you need help with that, check out how to
<a href="/rails/adding-jquery-to-rails6-webpacker/">install jQuery using Webpacker in Rails 6</a>.
You should be all set to handle nested forms in your Rails app now. If I missed anything, let me know in the comments!
</p>Curtis MillerIf you're not familiar with the Cocoon gem, it's an awesome little gem to help with easily handling nested forms. We've used it with great success on many of our Rails projects.Rails 6, Webpacker, and jQuery2020-06-15T10:00:00+00:002020-06-15T10:00:00+00:00https://millarian.com/rails/adding-jquery-to-rails6-webpacker<p>
I'm finally getting around to using Rails 6 (hooray for legacy projects!) and learning about some of the differences. One of those, I encountered was how to add jQuery to our application.
</p>
<p>
Most of our legacy projects include the <code>jquery-rails</code> gem. You might be able to guess how old those projects are! Looks like the new, preferred way is to use yarn to add JavaScript dependencies. No problem!
</p>
<p>
From the root of your Rails directory run:
</p>
<figure class="highlight"><pre><code class="language-shell" data-lang="shell">yarn add jquery</code></pre></figure>
<p>
You should now see jquery listed in your <code>package.json</code> file. Awesome! Now let's add it to <code>/app/assets/javascripts/application.js</code>. What do you mean that file doesn't exist??
</p>
<p>
Okay, so our JavaScript files have moved from <code>/app/assets/javascript</code> to <code>/app/javascript/packs</code> and there's a new way to include them in your views using <code>javascript_pack_tag</code> instead of <code>javascript_include_tag</code>. Right, no problem.
<p>
<p>
In <code>/app/javascript/packs/application.js</code> add jQuery to your list of requires:
</p>
<figure class="highlight"><pre><code class="language-javascript" data-lang="javascript"><span class="nx">require</span><span class="p">(</span><span class="dl">"</span><span class="s2">jquery</span><span class="dl">"</span><span class="p">)</span></code></pre></figure>
<p>
Just one last thing we need to do to be able to use jQuery, though. In your <code>/config/webpack/environment.js</code> file add:
</p>
<figure class="highlight"><pre><code class="language-javascript" data-lang="javascript"><span class="kd">const</span> <span class="nx">webpack</span> <span class="o">=</span> <span class="nx">require</span><span class="p">(</span><span class="dl">'</span><span class="s1">webpack</span><span class="dl">'</span><span class="p">)</span>
<span class="nx">environment</span><span class="p">.</span><span class="nx">plugins</span><span class="p">.</span><span class="nx">prepend</span><span class="p">(</span><span class="dl">'</span><span class="s1">Provide</span><span class="dl">'</span><span class="p">,</span>
<span class="k">new</span> <span class="nx">webpack</span><span class="p">.</span><span class="nx">ProvidePlugin</span><span class="p">({</span>
<span class="na">$</span><span class="p">:</span> <span class="dl">'</span><span class="s1">jquery/src/jquery</span><span class="dl">'</span><span class="p">,</span>
<span class="na">jQuery</span><span class="p">:</span> <span class="dl">'</span><span class="s1">jquery/src/jquery</span><span class="dl">'</span>
<span class="p">})</span>
<span class="p">)</span></code></pre></figure>
<p>
This should go just before the line that exports the environment. Think of this file as similar to your Rails <code>/config/environment.rb</code>, in that it contains the common JS stuff across all environments. You may notice that there are per environment JS files (development.js, production.js, test.js) there as well to allow you to specify JS per environment.
</p>
<p>
You should be all set to use jQuery in your Rails app now. If I missed anything, let me know in the comments!
</p>Curtis MillerI'm finally getting around to using Rails 6 (hooray for legacy projects!) and learning about some of the differences. One of those, I encountered was how to add jQuery to our application.Importing Heroku PostgreSQL to localhost2019-07-03T08:00:00+00:002019-07-03T08:00:00+00:00https://millarian.com/ops/importing-heroku-postgresql-to-localhost<p>
It can sometimes be useful to operate against a more robust set of data on your local machine, especially when you're seeing different behavior locally vs on staging/production. If you're using Heroku with PostgreSQL, this can be very easy with the right set of commands.
</p>
<p>
From the root directory of your project request that a new backup be created on Heroku.
<p>
<figure class="highlight"><pre><code class="language-shell" data-lang="shell"> heroku pg:backups:capture</code></pre></figure>
<p>
NOTE: If you have more than one Heroku app available, then you'll need to specify which one by using the `-a APP` or `-r REMOTE` options.
</p>
<p>
You should now have a backup available to you, which you'll want to download to your local machine. Heroku also offers a command to help with grabbing the latest backup. Again, you may need to specify the app or remote here.
</p>
<figure class="highlight"><pre><code class="language-shell" data-lang="shell"> heroku pg:backups:download</code></pre></figure>
<p>
Finally, you can restore this backup (<code>latest.dump</code>) to your local PostgreSQL database. This will overwrite the database specified, so be cautious.
</p>
<figure class="highlight"><pre><code class="language-shell" data-lang="shell"> pg_restore <span class="nt">--verbose</span> <span class="nt">--clean</span> <span class="nt">--no-acl</span> <span class="nt">--no-owner</span> <span class="nt">-h</span> localhost <span class="nt">-d</span> <span class="o">[</span>DATABASE NAME] latest.dump</code></pre></figure>
<p>
Happy debugging!
</p>Curtis MillerIt can sometimes be useful to operate against a more robust set of data on your local machine, especially when you're seeing different behavior locally vs on staging/production. If you're using Heroku with PostgreSQL, this can be very easy with the right set of commands.Easily Add An Instagram Feed To Jekyll2018-07-12T16:00:00+00:002018-07-12T16:00:00+00:00https://millarian.com/code/adding-an-instagram-feed-to-jekyll<p class="lead">
I've had a Flickr integration on here for years, but don't post there much anymore. Felt it was time to update my photo stream to Instagram.
</p>
<p>
The process is fairly straightforward, but you'll need a few pieces of information first and a bit of setup.
</p>
<h3>Your Instagram User ID</h3>
<p>
You'll need the numeric ID of your Instagram account. I used this tool to
<a href="https://codeofaninja.com/tools/find-instagram-user-id">find my Instagram User ID</a>. Copy that somewhere, you'll need it soon.
</p>
<h3>A Registered Instagram Client</h3>
<p>
Sign into your Instagram account and then head over to
<a href="https://www.instagram.com/developer/clients/register/">register your client</a>.
There will be a few required pieces of information to create the client:
</p>
<dl>
<dt>Application Name</dt>
<dd>You can just use your website name.</dd>
</dl>
<dl>
<dt>Description</dt>
<dd>Something descriptive…</dd>
</dl>
<dl>
<dt>Website URL</dt>
<dd>Your website's URL.</dd>
</dl>
<dl>
<dt>Valid redirect URIs</dt>
<dd>Your website's URL, again.</dd>
</dl>
<p>
Next, there will be a <i>Security</i> tab at the top. It's easy to miss, but you need to uncheck <b>Disable implicit OAuth</b>. This is important!
</p>
<p>
Once you've submitted the registration, you should see your client, with a Client ID. You'll need this ID for the next step.
</p>
<h3>Get Your Access Token</h3>
<p>
Copy and paste the following URL into your browser, replacing <code>CLIENT_ID</code> and <code>REDIRECT_URI</code> with your values:
</p>
<p>
<code>https://instagram.com/oauth/authorize/?client_id=CLIENT_ID&redirect_uri=REDIRECT_URI&response_type=token</code>
</p>
<p>
If all goes correctly, you should be on your redirect URI and there should be an access token as part of the path. Copy the access token, as you'll need it to make requests to Instagram.
</p>
<h3>Displaying Images</h3>
<p>
There's a simple JavaScript library that you can use to display Instagram images, called
<a href="http://instafeedjs.com/">Instafeed.js</a>. Follow their installation instructions to add the JavaScript to your Jekyll site. You can always refer to
<a href="https://github.com/curtis/curtis.github.io">the source of this site</a>
if you want to see what I did.
</p>
<p>
Next, add a <code>div</code> with an id of <code>instafeed</code> where you'd like your images to display. Regenerate your Jekyll site and viola, Instagram images! Style them as you like.
</p>
<p>
By default, it will return the latest 20 images, which for my purposes, was more than enough. You can see
<a href="/photos">my photos page here</a>.
</p>
<p>
<b>One thing to note, that caused me some trouble.</b>
If you want to use a different template to display your images, be sure to escape the <code>{</code> and <code>}</code> characters, or Jekyll will try to process them first and your template won't work. See <a href="http://instafeedjs.com/#templating">templating</a>.
</p>Curtis MillerI've had a Flickr integration on here for years, but don't post there much anymore. Felt it was time to update my photo stream to Instagram.Imagemagick On Heroku-162018-06-12T10:00:00+00:002018-06-12T10:00:00+00:00https://millarian.com/ops/imagemagick-memory-issues-on-heroku-16<p class="lead">
We recently upgraded from Heroku's Cedar-14 stack to their Heroku-16 stack after receiving a stack deprecation warning.
</p>
<p>
First we prototyped this upgrade with our staging server and, after a week, did not encounter any issues. Feeling pretty confident with Heroku, we initiated the update. Within 24 hours we were experiencing extreme memory issues (<a href="https://devcenter.heroku.com/articles/error-codes#r15-memory-quota-vastly-exceeded">R15 - Memory quota vastly exceeded</a>), causing the site to be unreachable.
</p>
<h3>Break Out The Fire Extenguisher</h3>
<p>
Okay, so we set our app on fire…
<b>this is fine.</b>
</p>
<p>
We looked at a lot of different possibilities, added extra monitoring, and ultimately made some changes to help improve the memory usage of the app. I may detail that in separate posts. However, something strange stuck out to us when we were investigating Imagemagick on Heroku.
</p>
<p>
Heroku typically gives each user a slice of the total system resources, a dyno. Unless you're on a performance dyno, you'll share the overall system resources with other applications. It seems like Heroku gives apps a little leeway when it comes to resources. For example, an app might temporarily use more memory than it was alloted, without serious repercussions, just some warnings.
</p>
<p>
We expected that Imagemagick would have some reasonable default limits in place that corresponded to the dyno size, but what we found surprised us. There were no limits set at all.
</p>
<script src="https://gist.github.com/curtis/33093c66bb62703f1f0a1cd63c7e0541.js"></script>
<p>
So, if you do want to prevent Imagemagick from using too many resources, you can user Heroku's config option to set <a href="http://www.imagemagick.org/script/resources.php#environment">Imagemagick environment variables</a>.
</p>
<script src="https://gist.github.com/curtis/eb097af4c9d1853269ecedda29854dde.js"></script>
<p>
<strong>
What do you think? Have a different workaround or solution?
</strong>
</p>Curtis MillerWe recently upgraded from Heroku's Cedar-14 stack to their Heroku-16 stack after receiving a stack deprecation warning.Jekyll Presentation at Ruby AZ2011-12-21T16:44:10+00:002011-12-21T16:44:10+00:00https://millarian.com/ruby/jekyll-presentation-at-ruby-az<p>
We recently switched from Wordpress to the Jekyll static site generator at my
<a href="http://velocitylabs.io">Ruby development company</a>,
Velocity Labs. So, I put together a Jekyll presentation based on that experience. Here are the slides, as presented at the
<a href="http://rubyaz.org/">Phoenix Ruby meetup</a>.
</p>
<h4 style="clear: both;">
<a href="https://www.slideshare.net/Velocity Labs/jekyll-presentation-slides" title="Jekyll Presentation Slides" target="_blank">Jekyll Presentation Slides</a><br />
</h4>
<div class="embed-responsive embed-responsive-16by9">
<iframe src="https://www.slideshare.net/slideshow/embed_code/10653919?rel=0" frameborder="0" marginwidth="0" marginheight="0" scrolling="no" class="col-sm-12"></iframe>
</div>Curtis MillerWe recently switched from Wordpress to the Jekyll static site generator at my Ruby development company, Velocity Labs. So, I put together a Jekyll presentation based on that experience. Here are the slides, as presented at the Phoenix Ruby meetup.How Twitter replaced my RSS reader2010-10-31T16:25:37+00:002010-10-31T16:25:37+00:00https://millarian.com/random/how-twitter-replaced-my-rss-reader<p>I used to subscribe to blogs via RSS through Bloglines, then Google Reader. Now, I don't subscribe to them at all. Strangely, RSS readers have become an obsolete, thing of the past for me and I didn't even realize it until recently.</p>
<p><strong>So, how has Twitter replaced my reader?</strong></p>
<ol>
<li><strong>I subscribe to people, not sites</strong>
<p>Subscribing to a site via RSS means that you subscribe to all of the content on that feed. With Twitter, you subscribe to people. The users you follow will (hopefully) weed out articles that are not interesting, so you don't need to. If they don't or if they have too much noise, then you can simply unsubscribe. Many RSS readers added "following" other users later, but by then it was too late.</p>
<p>Also, with only 140 characters, people get to the point about where the link goes. That makes it easy to ignore links that don't sound interesting.</p>
</li>
<li><strong>I get direct recommendations</strong>
<p>People I follow tweet a link to an article. This is the simplest and easiest way to read interesting articles since I'm already following people I find interesting.</p>
</li>
<li><strong>I also get indirect recommendations</strong>
<p>People I follow retweet (RT) a post, from someone I don't follow, that contains a link to an article. It seems like the volume of RTs has increased over the last 6 months; people are sharing more. This could be due to the ease with which the Twitter interface and mobile app allow RTs. This also gives me a chance to discover new, interesting people that I might want to follow.</p>
</li>
<li><strong>I can randomly discover articles</strong>
<p>I have several saved searches and lists that I check periodically. A majority of people I see on there are not people I follow. When I check these, I often discover content that I would have missed otherwise.</p>
<p>Combine that with straight up search and managing multiple accounts and I find random stuff all the time.</p>
</li>
<li><strong>I can bookmark an article</strong>
<p>I don't always have time to read a link right away, so I use the favorite feature as a way to bookmark a tweet until I have time to come back and read it. If you look at my favorites, they are overwhelmingly tweets containing a link.</p>
</li>
<li><strong>I can share easily</strong>
<p>If I write something or find something that's interesting, I'm likely to tweet/RT it. Twitter made it easy for sites to embed a share button, too. People can easily (un)follow me if it's (un)interesting.</p>
</li>
</ol>
<p>When I look at the current feature set of my RSS reader, it does the same things I described above, but checking it has constantly felt like a chore. I've already worked Twitter into my daily routine for communication, so there isn't another site I need to log into to find articles. Additionally, I also don't need to manage 2 sets of people I'm following.</p>
<p><strong>Truthfully, I can't think of a reason to keep using an RSS reader. Can you?</strong></p>
<p><strong>Update</strong>: Found these links from Business Insider: <a href="http://read.bi/c4r7KG">Twitter Has Killed RSS Readers</a> and PaidContent.org: <a href="http://cnt.to/mkx">The Death Of The RSS Reader</a>.</p>Curtis MillerI used to subscribe to blogs via RSS through Bloglines, then Google Reader. Now, I don't subscribe to them at all. Strangely, RSS readers have become an obsolete, thing of the past for me and I didn't even realize it until recently. So, how has Twitter replaced my reader? I subscribe to people, not sites Subscribing to a site via RSS means that you subscribe to all of the content on that feed. With Twitter, you subscribe to people. The users you follow will (hopefully) weed out articles that are not interesting, so you don't need to. If they don't or if they have too much noise, then you can simply unsubscribe. Many RSS readers added "following" other users later, but by then it was too late. Also, with only 140 characters, people get to the point about where the link goes. That makes it easy to ignore links that don't sound interesting. I get direct recommendations People I follow tweet a link to an article. This is the simplest and easiest way to read interesting articles since I'm already following people I find interesting. I also get indirect recommendations People I follow retweet (RT) a post, from someone I don't follow, that contains a link to an article. It seems like the volume of RTs has increased over the last 6 months; people are sharing more. This could be due to the ease with which the Twitter interface and mobile app allow RTs. This also gives me a chance to discover new, interesting people that I might want to follow. I can randomly discover articles I have several saved searches and lists that I check periodically. A majority of people I see on there are not people I follow. When I check these, I often discover content that I would have missed otherwise. Combine that with straight up search and managing multiple accounts and I find random stuff all the time. I can bookmark an article I don't always have time to read a link right away, so I use the favorite feature as a way to bookmark a tweet until I have time to come back and read it. If you look at my favorites, they are overwhelmingly tweets containing a link. I can share easily If I write something or find something that's interesting, I'm likely to tweet/RT it. Twitter made it easy for sites to embed a share button, too. People can easily (un)follow me if it's (un)interesting. When I look at the current feature set of my RSS reader, it does the same things I described above, but checking it has constantly felt like a chore. I've already worked Twitter into my daily routine for communication, so there isn't another site I need to log into to find articles. Additionally, I also don't need to manage 2 sets of people I'm following. Truthfully, I can't think of a reason to keep using an RSS reader. Can you? Update: Found these links from Business Insider: Twitter Has Killed RSS Readers and PaidContent.org: The Death Of The RSS Reader.Say hello to the new Phoenix OpenCoffee Club2010-09-01T17:43:31+00:002010-09-01T17:43:31+00:00https://millarian.com/startups/say-hello-to-the-new-phoenix-opencoffee-club<p>When the Phoenix chapter of OpenCoffee Club was started, it got by at first with a group on Yahoo's Upcoming event site. That worked for a little while, but I don't consider it to be a very good platform. Later, when <a rel="external" href="http://brian.shaler.name">Brian Shaler</a> took up the challenge presented by event organizers in Phoenix and created Eventification, a site dedicated to providing a single place to find out about <a rel="external" href="http://eventification.com">business and technology events in Phoenix</a>, we were one of the first to move our group over there. It's a much better platform than it was when we first started promoting through it and we're happy to see that it's grown and improved.</p>
<p>However, as we pass the 18 month mark of organizing this weekly event for entrepreneurs, I felt that I'd like to do more with the group. What I'd really like is for the conversations and information sharing we're doing at the weekly event to continue online. So, thanks to some prodding from <a rel="external" href="http://marcchung.com/">Marc Chung</a>, I threw together a site<sup>1</sup> so that entrepreneurs in Phoenix can ask questions, submit posts and keep up on the latest news and events<sup>2</sup>.</p>
<p>It's intended to be a community site, so feel free to <a rel="external" href="http://phxoc.com/ask">ask questions</a> about small business, entrepreneurship, investment, technology or whatever else you can think of and we'll do our best to answer them. Additionally, the community can <a rel="external" href="http://phxoc.com/submit">submit posts</a> that will appear on the site (after moderation). The posts can be text, video, images, audio, etc., which is pretty cool. I think there are other things that we could add to it, but I'd like to get some feedback first.</p>
<p><strong>So, without further ado, go check it out the new <a rel="external" href="http://phxoc.com">Phoenix OpenCoffee Club</a> website and let me know your thoughts!</strong></p>
<ol>
<li class="small">
I researched various options and settled on Tumblr as the platform because it provides all of the functionality I was looking for and is extremely easy to use. I also don't need to host it myself...
</li>
<li class="small">
We're still using and promoting scheduling events through Eventification. I even added a small bit of JavaScript that pulls the latest OpenCoffee Club event from the Eventification API and prominently displays it in the header. I'm also working on creating a series of <a rel="external" href="http://github.com/curtis/eventification-widgets">event distribution widgets</a> for Eventification.
</li>
</ol>Curtis MillerWhen the Phoenix chapter of OpenCoffee Club was started, it got by at first with a group on Yahoo's Upcoming event site. That worked for a little while, but I don't consider it to be a very good platform. Later, when Brian Shaler took up the challenge presented by event organizers in Phoenix and created Eventification, a site dedicated to providing a single place to find out about business and technology events in Phoenix, we were one of the first to move our group over there. It's a much better platform than it was when we first started promoting through it and we're happy to see that it's grown and improved. However, as we pass the 18 month mark of organizing this weekly event for entrepreneurs, I felt that I'd like to do more with the group. What I'd really like is for the conversations and information sharing we're doing at the weekly event to continue online. So, thanks to some prodding from Marc Chung, I threw together a site1 so that entrepreneurs in Phoenix can ask questions, submit posts and keep up on the latest news and events2. It's intended to be a community site, so feel free to ask questions about small business, entrepreneurship, investment, technology or whatever else you can think of and we'll do our best to answer them. Additionally, the community can submit posts that will appear on the site (after moderation). The posts can be text, video, images, audio, etc., which is pretty cool. I think there are other things that we could add to it, but I'd like to get some feedback first. So, without further ado, go check it out the new Phoenix OpenCoffee Club website and let me know your thoughts!Arizona’s First Ruby Conference - SunnyConf 20102010-08-19T16:45:13+00:002010-08-19T16:45:13+00:00https://millarian.com/ruby/arizonas-first-ruby-conference-sunnyconf-2010<p>It started as an impromptu chat about getting more Ruby sessions into events like Desert Code Camp. A small group of rubyists met in the courtyard of DeVry University after the lunch break and kicked around some ideas. It seems like only yesterday that the group, which represented about 5 Phoenix companies, was asked "<strong>Wait... what about having a Ruby conference in AZ?</strong>" Now, that idea has blossomed into a full-fledged <a rel="external" href="http://sunnyconf.com">regional Ruby conference, SunnyConf 2010</a>.</p>
<div style="float:right;">
<iframe src="https://www.eventbrite.com/countdown-widget?eid=769378231" frameborder="0" height="376" width="220" marginheight="0" marginwidth="0" scrolling="no"></iframe>
</div>
<p>SunnyConf is a single-track, one day conference taking place Sept. 25th in Phoenix. There will be 8 speakers and a keynote, as well as lightning talks. There will also be time after the conference set aside for hacking. We've managed to pull together a great group of rubyists to share their knowledge. The speakers include:</p>
<ul>
<li><a href="http://ashkenas.com">Jeremy Ashkenas</a> (Keynote)</li>
<li><a href="http://hashrocket.com/people/view/les-hill/">Les Hill</a> & <a href="http://hashrocket.com/people/view/jim-remsik/">Jim Remsik</a> of <a href="http://hashrocket.com">HashRocket</a></li>
<li><a href="http://blog.headius.com/">Charles Nutter</a></li>
<li><a href="http://github.com/bmizerany">Blake Mizerany</a></li>
<li>and <a rel="external" href="http://sunnyconf.com/#speakers">more</a>!</li>
</ul>
<p>You can find all of the date, time and location information in the widget to the right. You can also visit the <a rel="external" href="http://sunnyconf.com">official SunnyConf website</a> or just jump straight over to Eventbrite to <a rel="external" href="http://sunnyconf.eventbrite.com">register for SunnyConf</a>.</p>
<p>Late September is a great time to visit Phoenix! If you live nearby (e.g., Southern California, Nevada, Utah, Colorado, New Mexico, etc.) then we're only a short drive, and an even shorter flight, away. If you're outside of that area, we have a major international airport, and plane tickets should be pretty cheap :)</p>
<p>I encourage you to come out to Arizona in September to learn, hack and meet other rubyists. <strong>I hope to see you at the conference!</strong></p>Curtis MillerIt started as an impromptu chat about getting more Ruby sessions into events like Desert Code Camp. A small group of rubyists met in the courtyard of DeVry University after the lunch break and kicked around some ideas. It seems like only yesterday that the group, which represented about 5 Phoenix companies, was asked "Wait... what about having a Ruby conference in AZ?" Now, that idea has blossomed into a full-fledged regional Ruby conference, SunnyConf 2010. SunnyConf is a single-track, one day conference taking place Sept. 25th in Phoenix. There will be 8 speakers and a keynote, as well as lightning talks. There will also be time after the conference set aside for hacking. We've managed to pull together a great group of rubyists to share their knowledge. The speakers include: Jeremy Ashkenas (Keynote) Les Hill & Jim Remsik of HashRocket Charles Nutter Blake Mizerany and more! You can find all of the date, time and location information in the widget to the right. You can also visit the official SunnyConf website or just jump straight over to Eventbrite to register for SunnyConf. Late September is a great time to visit Phoenix! If you live nearby (e.g., Southern California, Nevada, Utah, Colorado, New Mexico, etc.) then we're only a short drive, and an even shorter flight, away. If you're outside of that area, we have a major international airport, and plane tickets should be pretty cheap :) I encourage you to come out to Arizona in September to learn, hack and meet other rubyists. I hope to see you at the conference!IE tries to be helpful when using JavaScript to set the href attribute2010-06-17T10:30:42+00:002010-06-17T10:30:42+00:00https://millarian.com/javascript/ie-tries-to-be-helpful-when-using-javascript-to-set-the-href-attribute<p>
Have you ever tried to set an anchor tag's <code>href</code> attribute using JavaScript? It's pretty easy, even without a JavaScript library (jQuery, Prototype, etc.). All you need to do is find (or create) the element and then set the href attribute to the desired text.
</p>
<p>
<script src="https://gist.github.com/436998.js"></script>
</p>
<p>
Now, try executing the following in IE:
</p>
<p>
<script src="https://gist.github.com/437011.js"></script>
</p>
<p>
What would you expect to be the value of <code>link.innerHTML</code>? Turns out that it is the same as the href value, 'http://flatterline.com'. It seems that, on IE only, if the inner HTML of an anchor tag looks like a URL, then upon replacing the href, it will also replace the inner HTML. Try the same experiment, but with link text that does not look like a URL:
</p>
<p>
<script src="https://gist.github.com/437016.js"></script>
</p>
<p>
Inspecting the innerHTML value will show that it was not replaced.
</p>
<p>
This is a browser level quirk, so using a JavaScript library won't save from this unless your library has specifically made a special case for this. I originally saw this when using jQuery and thought it might be a problem with the jQuery framework.
</p>
<p>
I think the best workaround here is that when modifying an anchor tag with JavaScript, set attributes first, then set the link text.
</p>
<p>
<strong>What do you think? Have a different workaround or solution?</strong>
</p>Curtis MillerHave you ever tried to set an anchor tag's href attribute using JavaScript? It's pretty easy, even without a JavaScript library (jQuery, Prototype, etc.). All you need to do is find (or create) the element and then set the href attribute to the desired text.