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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T17:14:46+00:00 2026-06-03T17:14:46+00:00

I have this function in module MessagesHelper : def message_block( message, ticket, comment )

  • 0

I have this function in module MessagesHelper:

def message_block( message, ticket, comment )
  content_tag( :div, :class => "message", :id => "message-" + message.id.to_s ) do
    content_tag( :p, message.body, :class => "message-body", :id => "message-body-" + message.id.to_s ) +

    content_tag( :div,  content_tag( :a, "add comment", :id => "comment-link-" + ticket.id.to_s, :class => "comment-link" ), :id => "comment-" + ticket.id.to_s, :class => "comment" ) +

    form_for( comment, :html => { :class => "add-comment", :id => "add-comment-" + ticket.id.to_s } ) do |f|
      f.label :body, "add comment"
      f.text_area :body
      f.submit "add comment"
    end
  end
end

To get this expected outcome:

<div class="message">
  <p></p>
  <div class="comment">
  </div>
  <form class="add-comment">
  </form>
</div>

In my partial view, _messages.html.erb:

<% if !@message.nil? %>
  <% @message.each do |m| %>
  <%= message_block( m, @ticket, @comment ) %>
<% end %>

The text_area does not even load in the DOM and I can only see the add comment button. This is all in the TicketController (not MessageController or CommentController).

Any help with my problem would be great. Thank you.

  • 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-03T17:14:49+00:00Added an answer on June 3, 2026 at 5:14 pm

    You’ve got a quite hard to read and maintain helper. I would suggest you to consider usage of partial for it.

    Here’s the example. Let’s say you want to render a lot of forms and you consider to create a helper which accepts some header, object for form and list of fields to be included in the form. Here the solution via partials.

    Create in your views/shared/_render_some_stuff.erb (note the underscore at the beginning):

    <%= title %>
    <%= form_for object do |f| %>
        <% fields.each do |field_name| %>
            <%= f.label field_name %>
            <%= f.text_field field_name %>
        <% end %>
    <% end %>
    

    And “inject” it in any view this way:

    <%= render 'shared/render_some_stuff', 
                title: 'Hello', object: Product.first, fields: [:title, :price] %>
    

    (Note: here no underscore at the beginning. You just need it to distinguish your partial in a directory, but not here)

    I guess it beats your approach?

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

Sidebar

Related Questions

I have a module that looks something like this: def __myFunc(): ... class MyClass(object):
i have created a module with this among others this function in it: <?php
I have this regexp var bodyRegExp = /function[\\s]+[(].+[)][\\s]+{(.+)}/; bodyRegExp.exec(module.exports = function () { /*
I have this class in my parser.py file class HostInfo(object): def __init__(self, host_id): self.osclass
In a file I have this code: module.exports.greet = function() {...} I want to
I have a function in a module that looks something like this: module MyLibrary
I have the following function in a Python module called dictbuilder.py: def my_dictbuilder(reader_o, writer):
For instance... if I have a Module class: class Module{ var $page; function Module($page){
Say i have this code to separate routes in expressjs: module.exports = function(express,app,client) {
I have done this function, using geocoder module, to get the city from 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.