-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
setup helpers for 'owner?' logic to clean up view
- Loading branch information
Showing
6 changed files
with
22 additions
and
20 deletions.
There are no files selected for viewing
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
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,14 +1,7 @@ | ||
module RecipesHelper | ||
def is_owner? | ||
if current_user.id == @recipe.user_id then | ||
return true | ||
else | ||
return false | ||
end | ||
end | ||
|
||
def user?(user) | ||
return true unless user.nil? | ||
def owner? | ||
owner_check(@recipe.user_id) | ||
end | ||
|
||
end |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
module RecipesHelper | ||
|
||
def owner? | ||
# owner_check(@recipe.user_id) | ||
owner_check(@workout.user_id) | ||
end | ||
|
||
end |
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
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
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
eed2a1a
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jatwell93
app/helpers/application.rb
to check against current_user.idworkouts
& 'recipes`) to test the ownerGoing forward, when you make a new view & want to check if the current_user is the owner, you just check the
app/helpers/[view_helper].rb
... if one exists you just copy the helper defined inapp/helpers/recipe_helpers.rb
called "owner?" and then change the@recipe.user_id
to@[controllerVar].user_id
. This of course assumes whatever new model/schema/controller you will have a has_many relationship pointing or if not you can do the@[model].user.id
type thing.