undefined method `devise_controllers?' - devise

I am trying to use paperclip 3.5.1 with devise 3.1.0 in a Rails 4 application.
I wanted to be able to add an avatar for my User devise model, so I generated the required fields but I have problem in the showing and saving the picture.
I tried the solution given here but when I try to load a url now I get for every controller that I have the following error. It even appears for the RegistrationController.
undefined method `devise_controllers?' for #<__Some__Controller:_____>
Why does this happen and how can I solve it? I couldn't find any solutions online and since it is my first rails application I'm not so familiar with it yet.

This is just a typo: the name of the helper is :devise_controller?, notice the extra "s" you have there: rubydoc reference

Related

Prestashop 1.7 Context::getContext() not working in AdminController

I have created custom admin controller in my custom module but i am not able to use Context::getContext() in my admin controller.
When i try to use that i am getting below error.
Attempted to call an undefined method named "getContext" of class "PrestaShop\PrestaShop\Adapter\Shop\Context".
Did you mean to call e.g. "getContextListShopID", "getContextListShopIDUsingCustomerSharingSettings", "getContextShopGroup" or "getContextShopID"?
I have already added this line at the top of my file use PrestaShop\PrestaShop\Adapter\Shop\Context;
but still facing same issue.
If anyone have any idea why Context::getContext() doesn't work I would like to hear it.
Thanks

Yii2 "Page not found" when using CRUD generator

I have succesfully used Yii2 Model & CRUD Generators to obtain some skeleton code files for my web app. Particularly, the CRUD Generator claims to have succesfully created its view files into:
<yii_root>/basic/views/<my_view_name>/*.php
which I got by leaving "View Path" field blank.
However, browsing to:
https://<my_site_FQDN>/basic/web/index.php?r=<my_view_name>/index
spits a "Not Found (#404)" error and I'm unable to find any useful info in the Yii2 debug logs.
Any idea on this matter shall be welcome.
Antonio
<my_view_name> this is a terrible way of looking at this. Read about MVC.
You are creating controllers, routes are to controllers not to views. Stop looking if the views are there... look if the controller is there. You never interact with a view, you always do with a controller. So, is your controller there? are you sure you have created it?
Also what is the controller name? if you have something like ProductCategory then the correct route is
https://<my_site_FQDN>/basic/web/index.php?r=product-category/index
and not
https://<my_site_FQDN>/basic/web/index.php?r=ProductCategory/index
Edit
Ok, I see your problem, stop putting folders under other folders and so on. You created your CRUD wrong. Your controller has to be directly under controllers not under controllers/bibliografia, the same goes for the model. Delete the files and start again with CRUD as probably your namespaces are also wrong.
In my case, Yii2 consistenly writes the following with gii CRUD auto-generator.
namespace app\Controllers;
Notice uppercase 'C' for Controllers. This causes 404 error.
It should be :
namespace app\controllers
This fixed my 404 error.
I found with Yii2 (advanced template) that the generated controllers had:
namespace app\controllers;
I had to change this to:
namespace frontend\controllers;
I fixed it by capitalizing the first letter of the controller name.
Controller name should start with capital letters.
If lower case is used, Controller generator won't throw any error, but you will get not found(404) error in the browser.
this threw an error:
app\controllers\testController
this worked:
app\controllers\TestController
Its very Simple, change the namespace and please be careful while creating CRUD..
change namespace app\controllers; to namespace backend\controllers;

Rails - How would I get the URL of a single image asset in the controller?

I've tried including ActionView::Helpers::AssetTagHelper and then using the image_path() method however it gives me grief:
undefined local variable or method `config' for ActionView::Helpers::AssetTagHelper:Module
There's probably something simple I'm missing. Any ideas?
I found the solution in Barlow's answer here: How can I use image_path inside Rails 3 Controller
view_context.image_path('/path/to/image')
seems to work for me, no need to include helpers in the Controller

Multi-step form in Rails 3 with Paperclip attachments

I'm creating a multi-part form in the style that Ryan Bates describes here:
http://railscasts.com/episodes/217-multistep-forms
http://asciicasts.com/episodes/217-multistep-forms (text-based version)
To summarize, I have one view (with a bunch of partials for each form step), and the form variables are stored in a session when the user clicks a next button and a different part of the form is displayed.
One of my form steps allows the user to upload several images via the Paperclip gem. The problem with that is that Rails is trying to upload the image data to the session, which is returning TypeError "can't dump File".
What is a good way to go about this?
UPDATE:
I've tried a bunch of gems (wizardly, acts_as_wizard, and some other smaller ones) but none of them seem to work with Rails 3.
I've also tried just storing the data in an array until the form is complete, but that was causing my controller to get huge and messy.
Saving models into the session is working unless you want to save a File into the session. The wizard plugins are using the session to store models between the steps. They do not produce errors on valid models in my case only on invalids.
So clearing out the attached file sounded a good idea, but in my case clearing out the paperclip attachment with Attachment#clear was not enough because it still wanted to save some File.
I've found out that the problem was with the #queued_for_write attribute in Attachment which still contained the data.
So the following two lines solved my problem:
unless #model.valid?
#model.image.clear
#model.image.queued_for_write.clear
end
This was a paperclip bug and was corrected in this commit.

Rails3 UJS response not evaluated

It gives me the creeps,i'm done, i need some help here, i reverted multiple times back but i can't find the error.
Simple controller (customers),a simple form for adding a customer via :remote => true and the controller does respond_to do |format| { format.js } . Works fine, renders my create.js.rjs template.
I work for a few hours without making any javascript changes or changes to my controllers or authorization etc.. and when i try it again it's not working anymore.
What i mean with not working: Controller gets called, record saved, all partials rendered. But no javascript evaluated, not even a simple alert(1) at the beginning of the file.
I tried with different prototype.js versions and different rails.js versions, but nothing helped. I hope someone has a clue about this or already experienced this.
It's not that i don't want to post code. But it won't help. Its basic code that works and, after some changes where i don't know what i really changed (some locales here, some css there, html templates from a completely different controller a bit..)..
Currently developing with: ruby 1.9.2, rails 3.0.3, prototype 1.7 RC3, rails.js from github.
SOLVED
How stupid, I missed the part where the template naming changed. My application templace was named "application.rhtml". It worked until now. As it stopped to work, I changed it to "application.html.erb" and now it's working.