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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T18:28:16+00:00 2026-06-09T18:28:16+00:00

Afternoon all, I have a post model, which has a song name, song string

  • 0

Afternoon all,

I have a post model, which has a song name, song string fields and a user_id field. A user can create a new song with up to 10,000 characters. Now when saving a short song it displays it all just fine in its entirety, however when a user enters a long song say over 400 chars, it seems to cut most of it off displaying only about 200 chars, the same happens when editing, add the remains of the song and it still cuts it off. Database is Mysql and checking in the console, it doesn’t seem to save the full entry either. The songs are written in keyboard format, e.g E T W R[TREW] | WEER. Ive had a google and haven’t found anything along these lines.

my code is as follows;

post.rb

class Post < ActiveRecord::Base
  attr_accessible :song, :song_name, :user_id, :rating
  has_many :comments, dependent: :destroy
  has_many :ratings, dependent: :destroy
  belongs_to :user

  before_save :rating

  validates_presence_of :user_id
  validates :song_name, presence: true, length: { maximum: 70 }
  validates :song, presence: true, length: { maximum: 10000 }

  default_scope order: "posts.created_at DESC" 

posts_controller.rb

def show
    @post = Post.find(params[:id])
    @comments = @post.comments
    @ratings = @post.ratings
    respond_to do |format|
      format.html 
      format.json { render json: @post }
    end
  end


  def new
    @post = Post.new
    respond_to do |format|
      format.html # new.html.erb
      format.json { render json: @post }
    end
  end

  def edit
    @post = Post.find(params[:id])
  end

  def create
    @post = current_user.posts.build(params[:post])
    respond_to do |format|
      if @post.save
        format.html { redirect_to @post, success: 'Post was successfully created.' }
        format.json { render json: @post, status: :created, location: @post }
      else
        format.html { render action: "new", error: "please sign in to post" }
        format.json { render json: @post.errors, status: :unprocessable_entity }
      end
    end
  end

  def update
    @post = Post.find(params[:id])
    respond_to do |format|
      if @post.update_attributes(params[:post])
        format.html { redirect_to @post, success: 'Post was successfully updated.' }
        format.json { head :no_content }
      else
        format.html { render action: "edit", error: "please try again" }
        format.json { render json: @post.errors, status: :unprocessable_entity }
      end
    end
  end

and the show.html.erb

<div class="center hero-unit">
    <h1><%= @post.song_name %></h1>
     <p>Transcript by: <%= @post.user.name %><br/>
     Rating: <%= @post.rating %>/10</p>
    <br/>
     <p><%= raw @post.song %></p>
    <br/>
     <span class="timestamp">
       updated <%= time_ago_in_words(@post.updated_at) %> ago.
    </span>
       <%= link_to 'Edit', edit_post_path(@post) %>
    <br/>
       <% if !signed_in %>
         please login to rate songs
       <% else %>
         <%= render partial: "ratings/form", locals: { post_id: @post.id }%>
      <% end %>
   </div>

<%= render partial: "comments/form", locals: { post_id: @post.id } %>
<%= render partial: "comments/show", locals: { comments: @comments, post_id: @post.id } %>

if anyone has any ideas it would be much appreciated, and if you need more code just ask. cheers Andy.

  • 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-09T18:28:17+00:00Added an answer on June 9, 2026 at 6:28 pm

    It might be that the database field is defined as a varchar which limits the string to 255 characters. But I’m sure you can quickly check that.

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

Sidebar

Related Questions

Good afternoon. I have a Model that has a field called percentage. All similar
Afternoon all, I have a Month model which has many hotels. A hotel belongs_to
Afternoon All, I have a web form that i wish my user to fill
Afternoon all. I have a drop down list in my view <div class=editor-label> @Html.LabelFor(model
Good afternoon all, I have a class which looks like this: public class Grapheme
I have a belonging model that allows user to post objects to be sold
Good Morning/Afternoon all, I have a ASP:grid which displays current versions of Terms and
Very good afternoon to all, The problem I have now is that I can
Good afternoon all Here is my scenario: I have user controls within a master
Afternoon, I have a LINQ query, which counts all products with a certain criteria.

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.