NameError in WelcomeController#index

13 views
Skip to first unread message

Stephanie_Snowflake

unread,
Jun 25, 2018, 3:02:44 PM6/25/18
to Ruby on Rails: Talk

Steps to reproduce

cd [app directory]
rails server
open localhost:3000/welcome/index

(Guidelines for creating a bug report are available
here
)

Expected behavior

I should be able to see the login screen for our ROR App (pcms.herokuapps.com)

Actual behavior

45 46 47 48 49 50def deny_access session[:forward_to] = request.fullpath redirect_to login_url end def check_admin

enter image description here

How to I get to the ROR app. Like it looks like the live site.

https://pcms.herokuapp.com/login

The app was designed by a previous developer in 2013. I just received the files two weeks ago. Having to update everything to latest versions of everything. I've added the database into the pgAdmin4.

I need to be able to see the changes in the localhost before pushing to heroku platform.

routes.rb

YES I am in the App Directory

System configuration

Rails version:
Rails 5.2.0
Ruby version:
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]

Walter Lee Davis

unread,
Jun 25, 2018, 3:17:06 PM6/25/18
to rubyonra...@googlegroups.com
What happens when you run the tests in your app? Try these steps:

1. cd into project directory
2. bundle
3. rm db/test.sqlite
4. RAILS_ENV=test rake db:migrate
5. rake

If that last step doesn't cause your tests to start running, try replacing that step with
bundle exec rspec spec

Nota bene: if you try this again later, you only need to re-run step 4 if you have made changes to the database structure with migrations (and none of the previous steps). You should be able to keep trying just step 5 (or the alternate, for rspec, as you make changes to the application to see if the tests pass now.

If the application was made a few years ago, as you said, then it wasn't made in Rails 5.2. How did you get it to that point? Do you have version control to step backwards if necessary for debugging?

If the tests don't run right off the bat, then I would step back in version control to the point where you got the code, and see if they run there. If they do, then you know that something you did while upgrading to 5.2 was the culprit.

If (I hope this is not the case) there aren't any tests at all, then you need to write some before you start updating Rails. Otherwise you are as well off just trying to rewrite the app altogether in the new version of Rails. It's really not a one-step bundle update rails and everything just works. There are a lot of differences between what was current two or three years ago and the just-released Rails 5.2.

Walter

> On Jun 25, 2018, at 3:03 PM, Stephanie_Snowflake <spicyc...@gmail.com> wrote:
>
> Steps to reproduce
>
> cd [app directory]
> rails server
> open localhost:3000/welcome/index
>
> (Guidelines for creating a bug report are available
> here)
>
> Expected behavior
>
> I should be able to see the login screen for our ROR App (pcms.herokuapps.com)
>
> Actual behavior
>
> 45 46 47 48 49 50 def deny_access session[:forward_to] = request.fullpath redirect_to login_url end def check_admin
>
>
> How to I get to the ROR app. Like it looks like the live site.
>
> https://pcms.herokuapp.com/login
>
> The app was designed by a previous developer in 2013. I just received the files two weeks ago. Having to update everything to latest versions of everything. I've added the database into the pgAdmin4.
>
> I need to be able to see the changes in the localhost before pushing to heroku platform.
>
> routes.rb
>
> YES I am in the App Directory
>
> System configuration
>
> Rails version:
> Rails 5.2.0
> Ruby version:
> ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-darwin17]
>
>
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/bc197399-b461-4a3c-ae6c-40e3b9851a78%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Stephanie_Snowflake

unread,
Jun 25, 2018, 3:48:16 PM6/25/18
to Ruby on Rails: Talk


On Monday, June 25, 2018 at 2:02:44 PM UTC-5, Stephanie_Snowflake wrote:

Steps to reproduce


USING POSTGRESQL 

Hassan Schroeder

unread,
Jun 25, 2018, 4:06:43 PM6/25/18
to rubyonrails-talk
On Mon, Jun 25, 2018 at 11:59 AM, Stephanie_Snowflake
<spicyc...@gmail.com> wrote:

> The app was designed by a previous developer in 2013. I just received the
> files two weeks ago. Having to update everything to latest versions of
> everything. I've added the database into the pgAdmin4.
>
> I need to be able to see the changes in the localhost before pushing to
> heroku platform.

1) Did it run locally with the original versions of "everything"?
2) Did the tests all pass originally?
3) Do the tests pass now?
4) Are there errors in the console when you start the app?

--
Hassan Schroeder ------------------------ hassan.s...@gmail.com
twitter: @hassan
Consulting Availability : Silicon Valley or remote

Stephanie_Snowflake

unread,
Jun 25, 2018, 4:12:10 PM6/25/18
to Ruby on Rails: Talk
Yes the original version ran fine. No errors. Just had to updated rails, ruby, gems, etc since the app is still running on the original version, and the platform asked us to update several things. 

Colin Law

unread,
Jun 25, 2018, 4:17:51 PM6/25/18
to Ruby on Rails: Talk
On 25 June 2018 at 21:12, Stephanie_Snowflake <spicyc...@gmail.com> wrote:
> Yes the original version ran fine. No errors. Just had to updated rails,
> ruby, gems, etc since the app is still running on the original version, and
> the platform asked us to update several things.

You have answered question 1 but not 2, 3 or 4.

Colin

>
> On Monday, June 25, 2018 at 3:06:43 PM UTC-5, Hassan Schroeder wrote:
>>
>> On Mon, Jun 25, 2018 at 11:59 AM, Stephanie_Snowflake
>> <spicyc...@gmail.com> wrote:
>>
>> > The app was designed by a previous developer in 2013. I just received
>> > the
>> > files two weeks ago. Having to update everything to latest versions of
>> > everything. I've added the database into the pgAdmin4.
>> >
>> > I need to be able to see the changes in the localhost before pushing to
>> > heroku platform.
>>
>> 1) Did it run locally with the original versions of "everything"?
>> 2) Did the tests all pass originally?
>> 3) Do the tests pass now?
>> 4) Are there errors in the console when you start the app?
>>
>> --
>> Hassan Schroeder ------------------------ hassan.s...@gmail.com
>> twitter: @hassan
>> Consulting Availability : Silicon Valley or remote
>
> --
> You received this message because you are subscribed to the Google Groups
> "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To view this discussion on the web visit
> https://groups.google.com/d/msgid/rubyonrails-talk/d6595e8d-e483-4c85-8083-9f7909b43eb6%40googlegroups.com.

Hassan Schroeder

unread,
Jun 25, 2018, 4:18:05 PM6/25/18
to rubyonrails-talk
On Mon, Jun 25, 2018 at 1:12 PM, Stephanie_Snowflake
<spicyc...@gmail.com> wrote:
> Yes the original version ran fine. No errors. Just had to updated rails,
> ruby, gems, etc since the app is still running on the original version, and
> the platform asked us to update several things.

That answered *1* question...

Stephanie_Snowflake

unread,
Jun 25, 2018, 4:24:34 PM6/25/18
to Ruby on Rails: Talk
Yes ran locally with the original versions of everything. Yes all the test passed. 

Currently the only error is on the Welcome Controller. 

No errors in the console

Hassan Schroeder

unread,
Jun 25, 2018, 4:30:19 PM6/25/18
to rubyonrails-talk
On Mon, Jun 25, 2018 at 1:24 PM, Stephanie_Snowflake
<spicyc...@gmail.com> wrote:
> Yes ran locally with the original versions of everything. Yes all the test
> passed.
>
> Currently the only error is on the Welcome Controller.
>
> No errors in the console

If there's a problem I'd expect it in the console or in the development
log file.

Where is this "error" you're seeing? Can you paste it in here?

Stephanie_Snowflake

unread,
Jun 25, 2018, 4:34:09 PM6/25/18
to Ruby on Rails: Talk
ERROR

localhost:3000/welcome/index

NameError in WelcomeController#index

undefined local variable or method `login_url' for #<WelcomeController:0x00007fa9da705068>

Extracted source (around line #47):
45
46
47
48
49
50
              
def deny_access
session[:forward_to] = request.fullpath
redirect_to login_url
end
def check_admin

Rails.root: /Users/snowflake/Documents/Current Website/pcms

Hassan Schroeder

unread,
Jun 25, 2018, 4:40:26 PM6/25/18
to rubyonrails-talk
On Mon, Jun 25, 2018 at 1:34 PM, Stephanie_Snowflake
<spicyc...@gmail.com> wrote:

> undefined local variable or method `login_url' for
> #<WelcomeController:0x00007fa9da705068>

So does 'login' show up when you run `rake routes`? How are you
authenticating?

Stephanie_Snowflake

unread,
Jun 25, 2018, 4:42:32 PM6/25/18
to Ruby on Rails: Talk
$rails routes

WARNING: Nokogiri was built against LibXML version 2.9.4, but has dynamically loaded 2.8.0
** Invoke routes (first_time)
** Invoke environment (first_time)
** Execute environment
** Execute routes
                   Prefix Verb URI Pattern                                                                              Controller#Action
            welcome_index GET  /welcome/index(.:format)                                                                 welcome#index
       rails_service_blob GET  /rails/active_storage/blobs/:signed_id/*filename(.:format)                               active_storage/blobs#show
rails_blob_representation GET  /rails/active_storage/representations/:signed_blob_id/:variation_key/*filename(.:format) active_storage/representations#show
       rails_disk_service GET  /rails/active_storage/disk/:encoded_key/*filename(.:format)                              active_storage/disk#show
update_rails_disk_service PUT  /rails/active_storage/disk/:encoded_token(.:format)                                      active_storage/disk#update
     rails_direct_uploads POST /rails/active_storage/direct_uploads(.:format)

Stephanie_Snowflake

unread,
Jun 25, 2018, 4:44:03 PM6/25/18
to Ruby on Rails: Talk
Rails.application.routes.draw do
     get 'welcome/index'

  resources :feedbacks, only: [:post]
Reply all
Reply to author
Forward
0 new messages