Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/crud admin user #17

Merged
merged 10 commits into from Jul 8, 2022
Merged

Feature/crud admin user #17

merged 10 commits into from Jul 8, 2022

Conversation

LeandroSoria2
Copy link
Owner

@LeandroSoria2 LeandroSoria2 commented Jul 1, 2022

What changes does this PR include?

Description
Add active admin gem and set up active admin and add sass rails gem
Summary
-Add to gem file active admin gem
-Add to gem file active admin gem
-Change application_controller
Trello
(https://trello.com/c/9narEXDz/30-3-as-an-admin-i-should-be-able-to-login-in-the-admin-page)

Comment on lines 2 to 15
def self.up
create_table :active_admin_comments do |t|
t.string :namespace
t.text :body
t.references :resource, polymorphic: true
t.references :author, polymorphic: true
t.timestamps
end
add_index :active_admin_comments, [:namespace]
end

def self.down
drop_table :active_admin_comments
end
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we define the change method here?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It was generated by active_admin, but I will change it.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm not sure if active admin comments are necessary here, I think you can disable them in the configuration file

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we are not going to use ActiveAdmin comments, then we need to remove this migrations as well

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I agree, this migration should be removed now that you've disabled comments in the configuration file @LeandroSoria2

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I changed in last commit

db/seeds.rb Outdated
@@ -5,3 +5,7 @@
#
# movies = Movie.create([{ name: "Star Wars" }, { name: "Lord of the Rings" }])
# Character.create(name: "Luke", movie: movies.first)
if Rails.env.development?
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Seeds are not meant to be run in production usually. I think we can remove this condition

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it's better to keep this validation just in case someone accidentally runs this on production, wdyt?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think this can be done by accident actually. This is a task that needs to be manually run. Also seeds should be idempotent

@@ -1,3 +1,2 @@
class ApplicationController < ActionController::Base
include DeviseTokenAuth::Concerns::SetUserByToken
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why is this being removed? Don't we need to add it somewhere else?

Copy link
Owner Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I have a problem with active admin and this is already in the API controller.

https://github.com/LeandroSoria2/TargetApi/blob/develop/app/controllers/api/v1/api_controller.rb

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@JulianPasquale It looks like including this line in the ApplicationController generates conflicts with active admin. He had another controller (ApiController) with this same DeviseTokenAuth inclusion already, which is the one he uses for endpoints, so he had to remove this line here in order to fix the issue he was having with active admin.

Here's a thread about the same issue Lean was having:

lynndylanhurley/devise_token_auth#47

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ah so this is in the ApiController as well. If that's the case then it's ok to remove this 👍

Copy link
Collaborator

@sebastiancaraballo sebastiancaraballo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please add Trello card link and include a preview on the PR description please

db/schema.rb Outdated Show resolved Hide resolved
Copy link
Collaborator

@AgostinaDev AgostinaDev left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💪

@LeandroSoria2 LeandroSoria2 merged commit 6ae811e into develop Jul 8, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants