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

Strong Parameters -> Asset upload error #11

Open
Allanon29 opened this issue Jun 23, 2013 · 0 comments
Open

Strong Parameters -> Asset upload error #11

Allanon29 opened this issue Jun 23, 2013 · 0 comments

Comments

@Allanon29
Copy link

Hi,

Thank You for this great gem! I am trying to implement it into one of my current projects ,but I have some small (or maybe not so small) bugs to report.

The gem created an Assets menu in ActiveAdmin which is great, but when I try to add an asset I get a Forbiddenattributes error. I guess this is because I use the strong parameters gem. I tried to create an assets.rb file in the admin folder to configure strong parameters, but it doesn't seem to work.

This is my Assets.rb file:
"ActiveAdmin.register Assets do

controller do 

    def new
      @asset = Asset.new
    end

    def create
      @asset = Asset.new(asset_params)
      @asset.save
      render active_admin_template('index.html.arb'), :layout => false
    end

    def show
      @asset = Asset.find_by_permalink(params[:id])
    end

      def edit
        @asset = Asset.find_by_permalink(params[:id])
      end

      def update
        @asset = Asset.find_by_permalink(params[:id])
        @asset.update_attributes(asset_params)
      render active_admin_template('edit.html.arb'), :layout => false
      end

    def destroy
      @asset = Asset.find_by_permalink(params[:id])
      @asset.destroy
      render active_admin_template('index.html.arb'), :layout => false
    end

      def asset_params
        asset_params = params.require(:asset).permit(:asset,:storage,:retained_storage,:storage_url)
      end

end

end "

The above approach works on other content assets.
Any idea why it doesn't with assets?

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

No branches or pull requests

1 participant