-
-
Save caike/781161 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Even when you create objects they should be properly scoped... Remember this example? | |
t = Tweet.new | |
t.status = "RT #{@tweet.user.name}: #{@tweet.status}" | |
t.original_tweet = @tweet | |
t.user = current_user | |
t.save | |
# A simplified version of this, properly scoped might look like this: | |
current_user.tweets.create( | |
:status => "RT #{@tweet.user.name}: #{@tweet.status}", | |
:original_tweet => @tweet | |
) | |
# This will automatically assign current_user to tweet.user, in other words, it will set tweet.user_id with current_user.user_id |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment