erb

Rails with nested form

百般思念 提交于 2019-12-25 18:21:50
问题 When I submit the form it creates the new Outfitter, but it does not create a new User. In the log it says 'Unpermitted parameters: utf8, authenticity_token, first_name, last_name, email, password, password_confirmation, commit' Modal html:(modal is in application.html.erb. Page is localhost:3000/pages/index) <div id="popup-outfitter-signup" class="modal popup"> <div class="modal-main rounded-10px"> <div class="modal-title"> Create your Outfitter<br/> </div><!-- end .modal-title --> <%=

Does rails use method: :patch for editing with _form.html.erb?

北城余情 提交于 2019-12-25 08:59:14
问题 I am following along with the Ruby on Rails tutorial guide for getting started and am in section 5.12 Using partials to clean up duplication in views. I understand why partials are used per the D.R.Y. convention, however, I am curious about a difference in the new.html.erb and edit.html.erb. Specifically, prior to using the partial _form.html.erb file, the edit.html.erb file explicitly called method: :patch <%= form_for :article, url: article_path(@article), method: :patch do |f| %> <% if

Rails - Linking stylesheet and javascript in layout causes syntax error - “Missing ///”

筅森魡賤 提交于 2019-12-25 08:00:44
问题 I came into work today to find that my project is throwing a syntax error for some reason, and I can't find a single thing about this error. When using the stylesheet_link_tag or javascript_include_tag helpers, I receive SyntaxError: [stdin]:1:1: missing /// . Some things I have noted are: If the links dont lead to a valid file, it compiles just fine. Even if the files are empty the error is still thrown so the syntax error is definitely in the erb, even though I havent changed my application

Rails erb preprocessing not happening in development mode

こ雲淡風輕ζ 提交于 2019-12-25 07:38:10
问题 For whatever reason, this first attempt at dynamic styling gets me a Sass::SyntaxError on the line below. It looks like the erb is not being pre-processed. /* app/assets/stylesheets/variables.css.scss.erb */ $headerHeight: <%= '15px' %>; It's in development mode. Any idea what could cause this? Here are my configuration options relating to assets in case that helps: # Application config.assets.enabled = true config.assets.initialize_on_precompile = true config.assets.version = '1.1' #

I can't access the keys of checkbox with javascript when I generate the checkbox dynamically

最后都变了- 提交于 2019-12-25 05:35:26
问题 I created a checkbox in my html.erb as the following: <%= check_box_tag(:fenix_fee_charged) %> <%= label_tag(:fenix_fee_charged, "FENIX_FEE_CHARGED") %> <%= check_box_tag(:fenix_fee_no_charged) %> <%= label_tag(:fenix_fee_no_charged, "FENIX_FEE_NO_CHARGED") %> I created the javascript to set one or another: $('#fenix_fee_charged').click(function(){ $('#fenix_fee_no_charged').removeAttr("checked"); }); $('#fenix_fee_no_charged').click(function(){ $('#fenix_fee_charged').removeAttr("checked");

Unable to clear text field with overridden submit method used for ajax implementation via Jquery 1.4

醉酒当歌 提交于 2019-12-25 04:45:32
问题 I have a functionality of posting messages to a group which works using AJAX via Jquery. When I click on the "Post" button which is the value of the submit_tag, javascript is rendered and the page without reloading displays the latest message posted. Basically the post_message.js.erb file is called. I am making use of the following tutorial to implement the same:- http://railscasts.com/episodes/136-jquery The code for post_message.js.erb looks like this:- $("#new_post").before('<div id ="new

Bootstrap Accordion Collapse not indexing divs correctly

别等时光非礼了梦想. 提交于 2019-12-25 04:19:28
问题 When trying to index divs so that the accordion buttons will collapse correctly, it's indexing every first contact in each category in my json file as 0 instead of indexing every contact no matter the category consecutively. Here's my erb file: <% @contacts.each do |category, hash| %> <div class="panel-group" id="accordion"> <div class="panel panel-default"> <div class="panel-heading"> <h3 class="panel-title"><%= category %></h3> </div> <div class="panel-body"> <ul class="list-group"> <% hash

CRUD Ownership of Items/Microposts in Rails App

喜你入骨 提交于 2019-12-24 20:42:28
问题 I have a simple rails app where users can create 'items', but on the master index page that lists all the items, there are 'Show, Edit, and Delete' links next to each 'item'. I understand that this is due to the fact that I used scaffolding to accomplish the items, but I'd like to make sure that people can only edit the ones that they created. This logic is a little above my head at the moment, as, like I've said before, am totally new to rails. User Controller: class UsersController <

How to render html content with erb tags in rails?

£可爱£侵袭症+ 提交于 2019-12-24 16:25:07
问题 I'm writing simple cms engine, and having a problem with dynamic content rendering, for example I prepare some page content with erb tags and helpers, how I can evaluate them in my view? Thanks. 回答1: if i understand you correctly, you want to store snippets that contain ERB markup somewhere and at runtime evaluate them in your real templates of your rails app. in this case, i think you will have to invoke ERB by hand. this is not really hard: require 'erb' name = "Rasmus" template_string =

Rails: Generate Unique Random Number for populating a CSS class String How To?

浪尽此生 提交于 2019-12-24 07:38:18
问题 So let's say we have a rails view with this code: <h1>Users who have the <%= @title.name %> Title</h1> <ul> <% @title.users.each do |user| %> <li><%= user.username %> <div class="rw-ui-container rw-urid-X"></div></li> <% end %> </ul> And what we want to do is to automatically print this line: <div class="rw-ui-container rw-urid-X"></div> Right aside each username the loop throws at us BUT we want X to be a different unique random number each time... How can this be accomplished? 回答1: May be