My delete button stopped working - ruby-on-rails

As I was building the app I get this error.
Unknown action
The action 'destroy' could not be found for UsersController
The problem I have is that I do have a destroy method in my users controller and the button was working just fine. It just decided to stop working all of a sudden.
I started coding in a mailer and that is when it stopped working. Let me know what code you would like to see.
Appreciate the help.

Suppose that web server restart didnt help...
Maybe you should check your routes... Do you have
resources :users
in routes.rb file? If so, could you show us the whole content of that file?

Related

Rails ActionController::MissingExactTemplate Error

I'm just starting out using rails and I've come a across an issue I can't seem to solve or find the solution to. For some reason when I opened up the project today I kept getting this error
ActionController::MissingExactTemplate (HomeController#index is missing a template for request formats: text/html)
This is my home_controller.rb under app/controllers
class HomeController < ApplicationController
def index
end
end
This is my index.html.erb under app/views/home
<p>Index</p>
my routes.rb
Rails.application.routes.draw do
root 'home#index'
end
I've also run rails app:update, to no success. I've looked around stackoverflow and other websites but can't seem to find a solution that has worked for me. Any help would be greatly appreciated.
I tried reproducing your issue with the setup you have described but the issue does not appear to me.
What the bug tells you is that Rails can't find the view associated with the controller function, which urges me to believe that the index.html.erb file is not in app/views/home, but in app/views/layouts/home. (empirically speaking, I did the same error when creating the project)
So, it just works now? I went away for a day came back and it works. I have a feeling it has something to do with me running this on a Windows machine, I've head of issues with Ruby on Rails and Windows, I'm believe I'll just setup a Linux VM to mitigate issues like this.

Does anyone know why a default rails app on the bitnami stack would refuse to allow the app root to be set?

I have just begun using rails so I apologize if this is a dumb question, but I have been googling for a few hours and I'm starting to get really frustrated.
I've set up an AWS Bitnami Rails stack using the free one on the AWS Marketplace, and I've been following the tutorial at http://guides.rubyonrails.org/getting_started.html to start getting my head around running an app functionally. (I've already done rails for zombies and ruby 101)
Basically, I get to section 4.3 which is supposed to set me up with the basic routing for the app and I can't seem to get it to work. No matter what I put in the routing file of the welcome_controller, the app just serves the template index file located at /opt/bitnami/ruby/lib/ruby/gems/2.3.0/gems/railties-4.2.5.1/lib/rails/templates/rails/welcome/index.html.erb
My routes.rb file is
Rails.application.routes.draw do
get 'welcome/index'
# The priority is based upon order of creation: first created -> highest priority.
# See how all your routes lay out with "rake routes".
# You can have the root of your site routed with "root"
root 'welcome#index'
and my welcome_controller is
class WelcomeController < ApplicationController
def index
end
end
I really hope someone can help.
I'm guessing this is some sort of really stupid config error but I have a feeling others might have it as well so maybe this could be of use in the future.
Two possibilities:
You didn't restart the rails server after you generated controller. Though, /welcome/index etc should still work without restart.
Your server is running from directory which doesn't have this code checked in. As your error log doesn't reports absence of routes altogether.

Blogit is not routing in rails 4

Hi guys,
I have just installed blogit into my Rails 4 application. When I go to /blog I get routing error of every single route I have got. I get "undefined local variable or method". It is like that it won't load my routes at all.
Not sure if it make sense though. Please let me know what you want me to put here so you guys can have a look.
I have current_user defined in ApplicationController.
In the installation what I didn't understand is "declare which of your models acts as blogger in your app". That might be the issue.
Thanks in advance.
In case someone is looking for this.
Answer trail is in here. It is Explained fully
So just to sum it up, I added main_app to all of the links in the view and all are good.
Basically when you are in the /blog you will be in the engine, and you need to tell the app the correct path. Thanks to emaxon.

How can I edit routes.rb in runtime dynamically from rails app?

I have a situation that I needed to edit routes.rb from rails app progammatically. Need an idea how to do it. I am rails beginner.
When you change something in "routes.rb" you must restart app, so It is very bad idea. You can do with one controller/route. This controller can redirect to some other other controller or do something so you can use ONE ROUTE in routes.rb. You can write some your code here and We will help you.

Delete/Destroy method doesn't work anymore? (Rails)

I'm encountering a very strange problem: my delete actions in rails don't work anymore.
Even if I create everything by the scaffold command, every click on delete just sends me to the show view of the object, which should be deleted.
script/generate scaffold myitem description:text
This isn't only in one project, but extends to new projects I create.
Any idea, where this is coming from? Or better: Any idea how to fix this?
(the only thing I can think of, is that some plugin broke my installation, I installed paperclip, but don't know how to uninstall it: where are my plugins?)
Removing link to jquery helped me.
You should be able to look in the log file to see what SQL is being generated for the delete, and what error it is being generated.
Actually the problem was probably Firefox. When I clicked on Answer you own question here on Stackoverflow, I had the very same problem: My request, wasn't processed properly. I was sent back to the normal question view, without having the ability to submit my own answer.
So after a restart of Firefox everything worked fine.
(I also reinstalled Ruby and Rails at the same time, so I can't be sure, if it was Firefox for sure).
I've seen this before (because I had the same problem). Perhaps this could help you:
Rails 3 :method=> :delete doesn't work in Internet Explorer
I follow this blog step by step and solve it!

Resources