Posted by Dmytro Shteflyuk on
under MySQL, Ruby & Rails · (13,603 views)
I have a good news: Sphinx Client API has been updated and now it supports all brand new features of the unstable Sphinx 0.9.8 development snapshot. What does it mean for you as a developer? What features you will get if you would decide to switch to the new version? I will describe most valuable improvements of the Sphinx in this article, and will show how to use them with new Sphinx Client API 0.4.0 r909.
Posted by Dmytro Shteflyuk on
under Ruby & Rails · (18,949 views)
If you are creating Ruby on Rails application like a blog, you most probably want to generate URLs using post titles. It’s good practice, because search engines like keywords in URL, and it looks more human-readable. Just compare: http://example.com/posts/10 and http://example.com/posts/generating-permalinks-from-string (yeah, it’s long, but self-descriptive). Anyways, this is small post about converting a title to a permalink.
Posted by Dmytro Shteflyuk on
under Ruby & Rails · (25,902 views)
RSpec has great feature — mock objects (mocks). In a few words: mock object imitates behavior of the object, which used by the tested methods. And simple example immediately:
1 2 3 4 5 6 7 8 9 10
describe UserHelper
it 'should generate correct link to user profile in user_link'do @user = mock('User') @user.stub!(:id, 10) @user.stub!(:new_record?, false) @user.stub!(:preferred_name, 'Dmytro S.') @user.stub!(:full_name, 'Dmytro Shteflyuk')
user_link(@user).should == link_to('Dmytro S.', user_url(:id=>10), :title=>'Dmytro Shteflyuk') end end