Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8095629
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T21:11:48+00:00 2026-06-05T21:11:48+00:00

I have a really hard time understanding routes and I hope someone can help

  • 0

I have a really hard time understanding routes and I hope someone can help me.

Here’s my custom controller

class SettingsController < ApplicationController
  before_filter :authenticate_user!

    def edit
      @user = current_user
    end

    def update
      @user = User.find(current_user.id)
      if @user.update_attributes(params[:user])
        # Sign in the user bypassing validation in case his password changed
        sign_in @user, :bypass => true
        redirect_to root_path
      else
        render "edit"
      end
    end
end

and I have the file settings/edit.html.erb and my link

<li><%= link_to('Settings', edit_settings_path) %></li>

The route

get "settings/edit"

doesn’t work for this, because then I get

undefined local variable or method `edit_settings_path' for #<#<Class:0x00000001814ad8>:0x00000002b40a80>

What route do I have to give this? I can’t figure it out. If I put “/settings/edit” instead of a path it messes up as soon as I’m on a other resource page because the resource name is put BEFORE settings/edit

Thx

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-05T21:11:50+00:00Added an answer on June 5, 2026 at 9:11 pm

    Following should do:

    get 'settings/edit' => 'settings#edit', :as => :edit_settings
    # you can change put to post as you see fit
    put 'settings/edit' => 'settings#update'
    

    If you use /settings/edit directly in link, you shouldn’t have problem with other resource name being prepended in path. However, without the leading slash, i.e. settings/edit it might have that issue.

    Reason why edit_settings_path is not working might be because you didn’t declare a named route. You have to use :as option to define by which method you will be generating this path/url.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am a total noob to android and really have very hard time understanding
I have a really hard time searching for this, because I have no idea
I am having a really hard time getting this to work. I have two
I have been having a really hard time debugging this error since the past
I'm new to programming and have had a hard time understanding recursion. There's a
I have a really hard time to find how downloading a file with the
I am having a really hard time getting this marshalling down. I have umanaged
I'm having a really hard time with the FlowLayoutPanel. I have a Winforms app
In software companies I have seen it's really hard to work on very large
I have really basic question. How can I get form id by input element

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.