four times seven plus three
. This was basically a way to get some more experience with regular expressions in Ruby. Apparently, Ruby has a Regexp syntax where you write /(?<hello>world)/.match("the world")
and it will give you a MatchData object; if you assigned it to a variable m_data
and write m_data[:hello]
, it will give you "world". This is useful if you want to find multiple matches in a string, and access each one by an independent variable. Additionally, under some very particular conditions, when I use the =~
operator, it will assign a local variable with the name between the <>
s and the value of the match associated with it. So in this case, if I did this in IRB: /(?<hello>world)/ =~ "the world"
and then entered hello
, it will respond with "world"
.We kept working on Arel stuff for a while. It was tough, but I managed to get basically everything done with one SQL query per task (it may have been 100%, but I can't remember, and possibly one of them was impossible to do without 2 queries).
We had lecture today where Avi showed us a pattern for creating users with different permissions (in the case of his blog, users need permission to create/edit a post, create/edit a comment, etc.). We also went over OmniAuth, which I already have some experience with from adding Facebook login to my project. It's a standardized system of user authentication using big websites like Facebook, Google, Twitter, etc. And it's a great way to keep your users from dealing with the hassle of making a new login just for your site, while saving you from shouldering the burden of dealing with encrypting passwords (and potentially making a mistake).
I got a lot of work done on my upcoming project today. I'm debating whether to blog about it beforehand, but I'll probably keep it secret... :)
Skills developed: Ruby Regexps, Arel, User Authentication and OmniAuth
No comments:
Post a Comment