ActiveAdmin - Allow non-logged-in users to view but not edit resources

ActiveAdmin - Allow non-logged-in users to view but not edit resources

By : Has9
Date : November 22 2020, 10:38 AM
seems to work fine ActiveAdmin lets you customise its permissions by providing a custom AuthorizationAdapter. This has an authorized? method that determines whether a user can perform an action. Here's an AuthorizationAdapter should allow logged-in admins to do anything, but others can only read data:
code :
class AdminOnlyEditAdapter < ActiveAdmin::AuthorizationAdapter
  def authorized?(action, subject = nil)
    :read == action || (user && user.admin?)
config.authorization_adapter = "AdminOnlyEditAdapter"

Share : facebook icon twitter icon
Rails ActiveAdmin - Edit the new resource-view

Rails ActiveAdmin - Edit the new resource-view

By : user2158094
Date : March 29 2020, 07:55 AM
wish of those help You can customize both the controller actions and the new resource view.
To edit the new action in the controller:
code :

controller do
  def new
    @resource = Resource.new
    .... # Your custom logic goes here

form html: { multipart: true } do |f|
  f.inputs "Resource Details" do
    f.input :title
    .... # Your input fields

    # This adds the image field. Be careful though 
    # the field name needs to be the same in your model

    f.input :image, as: :file, required: false

I Want to allow users who are logged in to edit their info

I Want to allow users who are logged in to edit their info

By : Skyler Hogan
Date : March 29 2020, 07:55 AM
Any of those help Sample steps
Sign up : insert into database with the assumption of the id is set as auto increment and primary key.
Django Update Profile View - Only allow logged in users to edit their own accounts

Django Update Profile View - Only allow logged in users to edit their own accounts

By : Arkasha Domanski
Date : March 29 2020, 07:55 AM
will be helpful for those in need Your function-based view should just about work. If you use the login_required decorator to make sure the user is logged in, then setting instance=request.user should be enough. You don't need the form.actual_user = request.user line
code :
from django.contrib.auth.decorators import login_required

def update_profile(request):
    user = request.user
    form = UserUpdateForm(request.POST, instance=user)

    if request.method == 'POST':
from django.contrib.auth.mixins import LoginRequiredMixin

class UpdateProfile(LoginRequiredMixin, generic.UpdateView):
    model = Designer
    form_class = UserUpdateForm
    success_url = reverse_lazy('home')
    template_name = 'main/profile_update.html'

    def get_object(self):
        return self.request.user
Only allow logged in/current users to edit their own post

Only allow logged in/current users to edit their own post

By : Muhammad Shihab
Date : March 29 2020, 07:55 AM
this one helps. I have a table of post in which users log into the application and can post an item. Ideally, I would like to have users edit only their post and no one else's. So far, I have it so that users are able to edit posts, but also edit others. , You can use something like:
code :
<% if user_signed_in? && current_user.id == @review.user_id %>
  <%= review.review %>
  <% if user_signed_in && current_user.id == review.user_id %>
    <%= link_to 'Edit', edit_review_path(review) %>
  <% end %>
Using ActiveAdmin to edit/create Users -- ForbiddenAttributesError

Using ActiveAdmin to edit/create Users -- ForbiddenAttributesError

By : Andrey Kotov
Date : March 29 2020, 07:55 AM
hop of those help? This is an existing problem with Active Admin: https://github.com/gregbell/active_admin/issues/2595
Which is a symptom of setting:
Related Posts Related Posts :
  • Rails 5 - Saving the absolute current url via a button to a cookie?
  • How can / should I override the `build` method for a my model?
  • Install Rails Failed on OSX 10.8.4
  • ruby on rails - undefined method valid?
  • Users Registration on POST
  • Rails application variables in carrierwave store_dir
  • How to customize simple_form for json nested hash
  • Couldn't find file 'jquery', Sprockets::FileNotFound in StaticPages#home error
  • How should I use the alias_method_chain for the build method?
  • how to create two custom registration forms in devise?
  • Rails 4 link_to Destroy not working in Getting Started tutorial
  • How does ruby on rails dynamically define `find_by_id`, `find_by_name` methods?
  • JBuilder dynamic keys for model attributes
  • `initialize': No such file or directory - getaddrinfo (Errno::ENOENT) when Rails new app
  • What is the Ruby equivalent of Node.js' socket.io?
  • Where rails store standard helpers?
  • how to check expected result matches any of give values in rspec?
  • Form submission to create multiple objects
  • Simple Twitter Login with Rails and Email confirmation
  • Where should helpful functions for my controller go in Rails?
  • Using session variable in the Model or the other way
  • Why can't I have ruby code and comments in Embedded Ruby?
  • Rails: How can I make an object available in all views?
  • Cannot enter simply form information into SQLite DB (Rails)
  • Rails - Retain form values on failed submission. Getting "First argument in form cannot contain nil or be empty&quo
  • How to handle STI and build related models automatically?
  • Suppress an error when saving a record in Rails
  • Rails AJAX reload the page. Why?
  • How to pass user attributes to action mailer
  • Custom Validator to Prevent an appointment from being scheduled too early in day?
  • Postgres Enable TCP/IP Connection
  • How do I avoid the circular argument reference warning in activesupport
  • Unable to push to heroku master because of rails/spring version error
  • deep nested routes in rails
  • Best approach to Users Profile Images in Rails App
  • RailsInstaller: Can I maintain the gem fold when re-installing a new version?
  • couldn't find file 'jquery-ui' i get this error even after having this file in my application.js
  • Ruby regex to split user and date text input
  • Tool like BetterErrors for JRuby?
  • redirect_to in action destroy ruby on rails
  • Where are the I18n.t link and reference paths?
  • Sending emails to multiple recipients in rails app
  • Rails, Devise, Sign up = write name in other Database
  • pass custom attribute on rspec factory_girl controller test
  • rails generate uses wrong version of Ruby
  • Duplicate Requests from a Browser
  • One action in Rails controller sends no data back
  • Local data (JSON) in Middleman inside a different path than /data
  • How to pass numbers in an array into a SQL statement
  • How to refactor this Model logic in Rails
  • :readonly key of belongs_to method doesn't work
  • Create a new view in directory
  • nested resources in devise
  • Yaml value with a leading `!`
  • Rails admin show username instead of User #5
  • Can't start WEBrick with Byebug on
  • Failing Rspec test of a FactoryGirl object
  • engine yard No application found matching remotes:
  • Rails 4 sessions cookie is not set
  • How do I flush a class method in Rails 4 using memcached?
  • shadow
    Privacy Policy - Terms - Contact Us © ourworld-yourmove.org