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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T03:22:54+00:00 2026-06-14T03:22:54+00:00

I want to modify following code in order to be able to write only

  • 0

I want to modify following code in order to be able to write only the file extension into a database. Now I read the file_content_type, but I need only to know the extension (it doesn’t matter for me that the extension can be changed) and to put it into a database.
upload_file_name has an extension already, but I need to extract it and put it in the same database-table as a new row.

ActiveRecord::Schema.define(:version => 20120731045929) do

  create_table "uploads", :force => true do |t|
    t.string   "upload_file_name"
    t.string   "upload_content_type"
    t.string   "user"
    t.integer  "upload_file_size"
    t.datetime "upload_updated_at"
    t.datetime "created_at",          :null => false
    t.datetime "updated_at",          :null => false
  end

end

And it is possible somehow to save the file_name without an extension?

  • 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-14T03:22:56+00:00Added an answer on June 14, 2026 at 3:22 am

    That looks like it’s from schema.rb.

    Don’t touch that one directly.

    If you look under /db/migrations you’ll have ruby files with messy looking file names. These are the ruby files that let you configure your database tables.

    • First add a column in the database.

    In the terminal, run rails generate migration add_file_content_type_to_uploads file_content_type:string

    • In Upload.rb model file, add file_content_type to attr_accessible

    attr_accessible :file_content_type

    • To find the extension, you can use File.extname.

    So maybe in your create method of uploads controller

    def create
      ...
      @upload.file_content_type = File.extname(params[:upload_file_name])
      ...
    end
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I want to match and modify part of a string if following conditions are
I want to modify something in Settings.secure database, just as the android Settings app
I want to modify some code in the Eclipse JDT itself (In the Debug
The following code lies within cellForRowAtIndexPath . 1.) i need to modify this code
I am have written the following code below to encode a bitarray into custom
Let's say I want to be able to log to file every time any
I'm trying to modify the following code to make it return the flash notice
I want to be clear about all the advantages/disadvantages of the following code: {
I want to modify a code so I can add a virtual guitar notes
Following is my code but the modal only appears when someone click on <a

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.