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 7636459
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T07:41:11+00:00 2026-05-31T07:41:11+00:00

I’ve created a basic framework for webapps (some static pages, user authentication, unit/integration testing

  • 0

I’ve created a basic framework for webapps (some static pages, user authentication, unit/integration testing with rspec). I’d like to use this as a foundation for future webapps, but I need to setup a way to rename it after cloning it from github. I got some help generating the renaming code here]1, but I’m struggling to figure out how to integrate it.

I originally wrote had the renaming code in a rakefile, but now I think maybe it should be in the controller. Unfortunately, I haven’t been able to make my code work. I’ve got a view that allows the user to enter a new name for the app. The idea is that the user would clone the framework repo, cd into the framework directory, start rails server, then go to local host on their browser to rename the file from there. But the view that’s suppose to enable that isn’t working.

views/namer/new/html.erb

  <h1>Rails Framework</h1>

  <%= form_tag "/namer" do %>
  <%= text_field_tag "appname" %>
  <%= submit_tag "Name Your App" ,  :action => 'create' %>
  <% end %>

I can’t get the “submit” action to work to work properly. Here’s what my controller looks like.

controllers/namer_controller.rb
  class NamerController < ApplicationController


      def index
        render('new') 
      end  

      def new
      end

     def create
       @appname = Namer.new(params[:appname])
       #first, change any instances of the term "framework" to the new name of the app   
       file_names = ['config/environments/test.rb', 'config/environments/production.rb',
               'config/environment.rb']
       file_names.each do |file_name|
         text = File.read(file_name)
         File.open(file_name, "w") { |file| file << text.gsub("Framework", @appname) }
       end
       #next,change the root path away from namer#new
       file_name ='config/routes.rb'
       text = File.read(file_name)
       File.open(file_name, "w") { |file| file << text.gsub("namer#new", "pages#home") }
       flash[:notice] = "Enjoy your app."
       render('pages/home')
     end 

   end

Any idea what I’m doing wrong?

Also, it the controller really the best place for the “renaming” code?

edit: here’s my routes.rb file.

Framework::Application.routes.draw do


  resources :users
  resources :sessions, :only => [:new, :create, :destroy]

  match '/signup',  :to => 'users#new'
  match '/signin',  :to => 'sessions#new'
  match '/signout', :to => 'sessions#destroy'

  match '/contact', :to => 'pages#contact'
  match '/about',   :to => 'pages#about' 
  match '/help',    :to => 'pages#help'

  root :to => "namer#new"

  match ':controller(/:action(/:id(.:format)))'

UPDATE: I’ve changed my code in a few ways.

  1. Routes: added post ‘/namer’ => ‘namer#create’
  2. Created a Renamer model. Models/renamer.rb is just “class Namer” and then “end.” (I removed the “< Base::ActiveRecord” because there’s no database involved.)
  3. Created a rake file for the renaming code. It just called “renamer.rake”.

Things are looking good, but I’m still looking for a way to call the rake file from the controller. Any suggestions?

UPDATE 2: Here’s my revised Create method for my controller. Now the renaming code is here instead of in a rake file.

def create
  @appname = Namer.new(params[:appname])
  file_names = ['config/environments/test.rb', 'config/environments/production.rb', 
    'config/environment.rb']
  file_names.each do |file_name|
  text = File.read(file_name)
  File.open(file_name, "w") { |file| file << text.gsub("Framework", @appname) }
  flash[:notice] = "Enjoy your app."
  render('pages/home')
 end
  • 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-05-31T07:41:12+00:00Added an answer on May 31, 2026 at 7:41 am

    Your routes file doesn’t have a “post” match for namer, looks like. Easiest way to rectify that would be to put this line in somewhere.

    post '/namer' => 'namer#create'
    

    The form_tag helper defaults to creating a post-method form, and if you’re creating a resource, that’s what you’d want — you just need to make sure your route is there for it. It’s possible that Rails doesn’t send POST actions through the catch-all route at the bottom, but it’s much better practice to ensure your routes are named somehow.

    Personally, I prefer resourceful routes whenever possible. Read up on them here; I promise it’s worth it.

    (If this doesn’t help… can you check to see if the code in your def create function is actually firing? Drop in a debugger line or a puts statement to find out.)

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

Sidebar

Related Questions

I’ve got some a basic framework for a webapp (some static pages, user authentication,
I have some basic (stupid) questions about AWS EC2 instances or AMIs. I created
I have created a) a basic application MVVMLight framework. b) another project in the
I've been experimenting with Rhino Mocks for unit testing my .Net Compact Framework application,
I have a user entity in my application where users input some basic information
after going through some basic tutorials on the app engine and the webapp framework,
I am trying to create application with Zend framework so I have created basic
I am trying to get some basic unit tests up and running on the
I am new to zend framework and having very basic doubt.I have created one
I have a Rails 3.2.2 application using Ruby version 1.9.2. I have created basic

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.