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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T12:15:32+00:00 2026-06-08T12:15:32+00:00

I have 2 controllers that render a single view and I need the view

  • 0

I have 2 controllers that render a single view and I need the view to change depending on my controller. What I have in mind is to have a JS var in my view that I can set depending on which controller was called.

To be a bit more thorough on my explanation, I need to get a string value set inside a var so I can use it like this (in a piece of JS on the application.js):

if (value_i_set_in_controller == "controller1") {
   // do something
} else {
   // do something else
}

Any hints? Until know I have been finding Rails pretty easy.

EDIT

I need to explain a bit more.

I have some js in my application.js which renders some objet.

$('#calendar').fullCalendar({
...
    // a future calendar might have many sources.
    eventSources: [{
        url: '/DYNAMIC_PATH',
        color: 'yellow',
        textColor: 'black',
        ignoreTimezone: true
    }],

I render this simply by having a calendar view with this :

<div id='calendar'></div>

I was thinking of doing something like this in the calendar view:

<div id='calendar'></div>

<script type="text/javascript">
  var calendar_source = <% @dyn_path %>;
</script>

Evidently it does not work… with this I would be able to read calendar_source var and us it in my js to set the eventSources properly.

  • 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-08T12:15:33+00:00Added an answer on June 8, 2026 at 12:15 pm

    I think you’re just missing quotes :

    <script type="text/javascript">
      var calendar_source = '<%= @dyn_path %>';
    </script>
    

    Anyway I need this kind of assignation often, it works perfectly 🙂
    If it still doesn’t work, look at the generated code and the JS console (firebug, chrome debugger …)

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

Sidebar

Related Questions

I have two view controllers that allow changes to the Address Book. The first
I am implementing view controllers that shall have different behaviour. They have a common
I have a partial view that is shared between two controllers and I'm trying
I have a single controller, Index , that manages several non-specialized informational pages (e.g
I'm having a problem displaying breadcrumbs with Zend_Navigation. I have a single controller that
I have a UITabBarController that contains two view controllers. One is the default view
I have set up a rails application that uses single table inheritance but I
I have many controllers that will have some similar behavior, e.g. the user should
I currently have a type that I inject into my controllers that's used for
I have created a new method in one of the project's controllers that it

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.