Skip to content

Instantly share code, notes, and snippets.

View marinados's full-sized avatar
🤓

Marina Starkova marinados

🤓
  • Swile
  • Nantes
View GitHub Profile

How to Nested

Let's imagine we want to assign pokemons to trainers.

We are creating a new_trainer form with checkboxes for each pokemon and their names next a checkbox to assign them to this new trainer, like this:

  • Salameche
@francois-blanchard
francois-blanchard / scope_no_relation.md
Last active May 12, 2016 08:20
scope for find no relation

scope for find no relation

class User < ActiveRecord::Base
  scope :without_tweet, -> { where.not(id: Tweet.select(:user_id).uniq) }
end

squash and commit

$ git checkout master
$ git merge --squash release_branch
$ git commit -m 'sprint #42'
$ git log
$ git push origin master
@francois-blanchard
francois-blanchard / presenters_in_rails.md
Last active April 27, 2016 14:38
Presenters in Rails

Presenters in Rails

Without presenter

View

<h1>@post.title</h1>
<span>@post.publication_status</span>
@yannvery
yannvery / RSpec_cheatsheet.md
Last active February 22, 2018 20:32
RSpec cheatsheet

RSpec Cheatsheet

Specs layers

 +-----------------------------------------------------------------------------------------+

   +----------+                                                       +------------------+
   |          |                                                       |                  |
   |  View    |                                                       |                  |
   |  Specs   |            View                                       |                  |
@francois-blanchard
francois-blanchard / full_search_sunspot.md
Last active January 20, 2016 15:53
Full search specific fields with sunspot (SOLR)
activity_log
boss_news
delayed_job
link_posts
link_tweets
posts
rating_histories
tweets
class MyKlass
  include
  CONSTANTS
  belongs_to
  has_one
  has_many
  accepts_nested_attributes_for
  attr_accessible
 validates
@francois-blanchard
francois-blanchard / checkbox_nested.md
Created April 3, 2015 14:45
Create nested attributes with checkbox

Create nested attributes with checkbox

# Class
has_many :sc_invited_celebrities
accepts_nested_attributes_for :proposed_posts, :sc_invited_celebrities, :answer_to_questions
# Controller
def new
 @social_campaign = SocialCampaign.new