twitter_oauth gem

Been struggling with trying to get the twitter OAuth gem set up. I understand that I need to set up the file somewhat similarly to what's in the gist below, however I have no idea how to actually implement it into my app. When I put it into a controller I get an uninitialized object XXXController::TwitterOAuth error.

The code above is what I'm lookin at atm, however I'm struggling with the actual implementation ie what file this logic should be put into (controller, view, helper, some other catagory I don't know about, and once I have that setting up the <%= link_to("Twitter Authorization", request_token.authorize_url) %> in the corresponding view, then having the information saved in the session when I'm redirected back to x view and having that information available for storage. 

Ruby Blocks -- why you no work?

Using the following block of code, I am confused as two why a seemingly interchangable line of code yields something a lot more desirable.

search = Twitter::Search.contains("ski").per_page(2).each do |r|
   r.text

end

Why does r.text yield a ton of crap  (profile_img_url, from_user, to_user_id, source, etc...) where calling search.first.text and search.second.text yield only what I want, the text of the body. 

Twitter Gem

I have now become painfully aware that I lack any experience with Ruby on Rails : / 

After installing the twitter gem on Rubyforge I took a look at the API and thought to myself, "this seems fairly self-explanatory." I later found that when I search for tweets containing key words, I can only search for one word at a time, a disappointment, but I believed I could get around that. I then tried to transfer my logic into Ruby... yeah, I ran into a bit of a problem.

When searching for tweets containing powder, I also want to filter out tweets containing other words, such as chili, makeup, or another type of powder that doesn't have to deal with snowboarding/skiing. My logic for pulling in and adding new tweets to the database looks something like this, atleast for the keyword powder. In this implementation badWords is an array full of strings that I don't want included in the tweet

def pullTweets

   NewTweets = Twitter::Search.new('powder').each do |i|

i.filter(badWords)

   end

end

 

def filter(badWords)

   badWords.each do |n|

 if self.include? n

   needed = false;

end

   end

   if needed == true

Tweet.create(self)

   end

end

 

Obviously the syntax is completely off, and the logic wouldn't be perfect even if the syntax was, but it's a good starting point. And now I've taken the time to write down a guide to what I want to do. All that's left is for me to find resources on Ruby and get this stuff to work properly.

...Yeah, messing around in the console shows me just how bad this is, time to get to work learning the correct syntax!

Rails: How do they work?

I need to improve my understanding of the basics: post, put, get, and delete. Being able to understand the RESTful architecture is key, and while I could got out and memorize HTTP method definitions, what I'm looking for is either a specific example of REST being used or a general overview of REST that's explained in terms that I can understand.

I found a specific example of REST in Section 8.1.1 of Michael Hartl's book "Ruby on Rails 3 Tutorial". The user model we created allowed for 4 accessable attributes: :name, :email, :password, and :password_confirmation. Following this section users are finally able to sign up for our site by defining these four attributes, and the HTML/Ruby that makes this possible is in listing 8.2 (Just scroll down a bit in the link). Through the book, wiki's, and random blog posts, I have come to believe that form_for() is a Ruby method that creates a new instance of the specified model (@user in this case) after which do |f| is called on the newly created object in order to define all of its attributes. However I'm having a hard time understanding blocks, does |f| represent the newly created object?

Another, more direct and (hopefully) easy question that can be answered. How can I learn how to write a concise regular expression? At the moment there's one string in particular that I want to get down. I'd like to be able to limit input to the following characters: U, M, T, W, R, F, S while allowing more than one character, but a maximum of one of each character. So while TWR is allowed TTW is not. I'm currently trying to experiment with Rubular however I can not seem to understand what exactly the matched result means, I'm also wondering if the Regex quick reference listed on Rubular is a comprehensive set of rules, or if there are others not listed there.

Thanks for any help you can give me!

RoR3 render_views

Seem to just have problem after problem trying to get my tests to work. While looking at the site, all my links work fine, the title's are correct, and the pages exist. However this was not always the case. When changing the title tag from "Ruby on Rails Tutorial Sample App | <%= @title %>" to <%= title %> I forgot to remove the @. This made the title method I had just defined absolutely useless, as I was just taking the site's @title variable as the title anyway. Because of this, 2/3 of my tests were failing (One tests that the title of the page is "Ruby on Rails Tutorial Sample App | @title", the other tests that the page exists, and the third tests to make sure that the pages exist at the proper URL). After fixing that test, for whatever reason the Terminal is now giving me an error "undefined local variable or method 'render views'".

I am thoroughly confused as to why I'm getting this error, especially as to why it would happen after changing the title's reference from just an instance variable to a method which references an instance variable. Also, I've reread the last couple chapters a few times each and for the life of me can't find a step I may have missed. 

The error is pointing to this exact piece of code, prolly shoulda put it in before an edit, but here it is: 

require 'spec_helper'

describe PagesController do

  render_views

PagesController tests make sure that the pages exist, and that they have the appropriate titles, it uses the have_selector and be_success methods

Second Edit: Although it may be considered giving up, I was able to utilize github for the first time. Just a bit of a setback, I think I may have accidentally deleted a directory I wasn't supposed to earlier, which was causing this problem in the first problem. I just hope to work through it without the problems this time.

Themes and the Mac

I still lack a header I like for this posterous page, but other than that and the missing background image, I think I like how this set up looks, atleast for the time being. I believe I'm done with blog themes for the time being; it's time for me to mvoe onto understanding a Mac, along with downloading Rails and finishing the tutorials in the Ruby on Rails 3.0 book I'm working through. Aside from this, all I have to do is keep up with the Twitter accounts and ready myself for the upcoming trip out to San Fran in a little over a week. While I've been busy the last phew weeks, it's definitely been worth it. I'm learning a lot, and more quickly than I expected as well. Now to get back to setting up Git on the mac...

Theme Work

Pretty close to finishing up the cousinwil theme, then I just gotta figure out a theme of my own, been looking at backgrounds and css that can be applied to images. http://www.w3schools.com has been very helpful with that. Also, I needed to find someway to get a link in my post, as I want it to be red, and am making sure that's working correctly. Either way, learned a lot this past week, especially about how helpful inspect  element is.

Posterous Revamped

I've made a number of customizations to my posterous account. When I first looked at the code for the default posterous skin, I wasn't sure how long I would sit staring at my computer screen, boggled. But as I continued to sift through the HTML I was able to see elements I was familiar with, and later recognize which references went to which objects. My next roadblock was the CSS. When I finally found out which tags I had to modify I thought I would just go into the CSS file and edit the tag. That plan didn't seem to get very far, but then I found the style tag and noticed that other tags were being modified within it. All that was left was the actual code, the easy stuff. Now I'm just posting to make sure everything I've done wasn't specific to the first post >.<.