Skip to content

Instantly share code, notes, and snippets.

View g-ilham's full-sized avatar

g-Ilham g-ilham

  • Russian, Republic of Tatarstan, Kazan
View GitHub Profile
@rusllonrails
rusllonrails / ORDER BY IDS SEQUENCE
Created March 31, 2014 06:53
ORDER BY IDS SEQUENCE
1. Mysql only
> ids = [11,31,29]
=> [11, 31, 29]
> Page.where(id: ids).order("field(id, #{ids.join(',')})")
2. Postrgesql variant
def self.order_by_ids(ids)
order_by = ["case"]
@rstacruz
rstacruz / index.md
Last active November 3, 2023 09:56
Rails models cheatsheet

Rails Models

Generating models

$ rails g model User

Associations

belongs_to

has_one

@zhengjia
zhengjia / capybara cheat sheet
Created June 7, 2010 01:35
capybara cheat sheet
=Navigating=
visit('/projects')
visit(post_comments_path(post))
=Clicking links and buttons=
click_link('id-of-link')
click_link('Link Text')
click_button('Save')
click('Link Text') # Click either a link or a button
click('Button Value')