Search Results

Search found 9437 results on 378 pages for 'rails newbie'.

Page 114/378 | < Previous Page | 110 111 112 113 114 115 116 117 118 119 120 121  | Next Page >

  • Is there anything like Zope Page Templates for Ruby on Rails?

    - by dan
    I have a Ruby on Rails app that I built myself, but which needs a redesign by a professional designer. I know most designers just give you Photoshop mockups and slices, but I would like to hire someone to implement the design as well, which means rewriting the css style sheets and the erb and haml templates. The problem is that I want someone else to implement the redesign without exposing my business logic code to the redesign implementer. Also, I wish there was a way to allow a designer to implement a redesign on a Ruby on Rails site without having to know anything about Ruby on Rails. Are either of these scenarios possible using any combination of software tools? I guess I'm looking for something like Zope Page Templates, but for Ruby on Rails. http://quintagroup.com/cms/zpthttp://quintagroup.com/cms/zpt

    Read the article

  • Deep relationships in Rails

    - by Neil Middleton
    I have some projects. Those projects have users through memberships. However, those users belong to companies. Question is, how do I find out which companies can access a project? Ideally I'd be able to do project.users.companies, but that won't work. Is there a nice, pleasant way of doing this?

    Read the article

  • Rescuing redirect :back after destroy in Rails?

    - by Andreas
    I'm looking for a best practice solution to be able to keep using redirect :back after a successful destroy action, as many items can be deleted from a variety of listings. Unfortunately that strategy fails for the one case when the delete is initiated from the item view itself. What approach do you recommend for this situation?

    Read the article

  • In MVC framworks (such as Ruby on Rails), do usually Model spell as singular and controller and view

    - by Jian Lin
    I usually see Ruby on Rails books using script/generate model Story name:string link:string which is a singular Story, while when it is controller script/generate controller Stories index then the Story now is Stories, which is plural. Is this a standard on Ruby on Rails? Is it true in other MVC frameworks too, like CakePHP, Symfony, Django, or TurboGears? I see that in the book Rails Space, the controller is also called User, which is the same as the model name, and it is the only exception I see.

    Read the article

  • Rails 3 fields_for agressive loading?

    - by Seth
    Hi all, I'm trying to optimize (limit) queries in a view. I am using the fields_for function. I need to reference various properties of the object, such as username for display purposes. However, this is a rel table, so I need to join with my users table. The result is N sub-queries, 1 for each field in fields_for. It's difficult to explain, but I think you'll understand what I'm asking if I paste my code: <%= form_for @election do |f| %> <%= f.fields_for :voters do |voter| %> <%= voter.hidden_field :id %> <%= voter.object.user.preferred_name %> <% end %> <% end %> I have like 10,000 users, and many times each election will include all 10,000 users. That's 10,000 subqueries every time this view is loaded. I want fields_for to JOIN on users. Is this possible? I'd like to do something like: ... <%= f.fields_for :voters, :joins => :users do |voter| %> ... <% end %> ... But that, of course, doesn't work :(

    Read the article

  • rails: best way to store comments in mysql

    - by ciss
    Hello. Okay i have two models: posts and comments. as you can think comments has column :post_id. My models Comments belongs_to :post Post has_many :comments So, this is pretty simple association but i have some problems with ordering comments. at first time, when i create my comments migration file i just add column :position. This column indicate comment position in the post. But now i think what where is more good way to do this. so i can't make my choise: 1) uses t.column :datatime :created_at, :default = Time.now() 2) or use timestamps? this is undiscovered for me, please tell me about your exp.

    Read the article

  • Rails 3: Link_to :remote => true with JQuery?

    - by Derek
    Question update: I have figured out that importing JQuery (even without using it at all) is causing :remote => true to not work properly. I get the following error in the Chrome console: Uncaught TypeError: Object [object Object] has no method 'dispatchEvent' (prototype.js:5653) And when the link is clicked, it throws the same error again before redirecting. Responder.erb.html <ul> <% @choices.each_with_index do |choice, index| %> <li><%= link_to choice, { :action => "submit_response", :id => @id, :response => index }, :remote => true %></li> <% end %> </ul> Example generated HTML: <ul> <li><a href="/poller/submit_response/yni?response=0" data-remote="true">True</a></li> <li><a href="/poller/submit_response/yni?response=1" data-remote="true">False</a></li> </ul>

    Read the article

  • Missing Required Gems - javan-whenever and cron job in rails

    - by Matenia Rossides
    Hi, I have finally managed to get javan-whenever gem working on my site5 server, and updating the crontab is quite easy, however whenever a cron job is run with the code that is generated, i get a "missing required gems" error where it lists about 8/10 of my gems. Has anyone else had this problem? If so, what would the solution be. The funny thing is that when it outputs where my gems are, this is all correct, and the gems are loading fine from within my application. Cheers, Matenia

    Read the article

  • STI and accepts_nested_attributes_for in rails

    - by ryanshackintosh
    I have models as follows: class Entity < ActiveRecord::Base has_many :addresses accepts_nested_attributes_for :addresses, :reject_if => lambda { |a| a[:label].blank?} , :allow_destroy => true end class Client < Entity before_save :set_type private def set_type self.type = "Client" end end class Address < ActiveRecord::Base belongs_to :entity end I have recently implemented accepts_nested_attributes_for on the /clients/new form, as follows: <% form_for(@client, :html => {:class => 'form'}) do |f| -%> <%= f.label :name %> <%= f.text_field :name -%> <%= f.label :phone %> <%= f.text_field :phone %> <% f.fields_for :addresses do |a| %> <%= a.label :street %> <%= a.text_field :street%> <%= a.label :city %> <%= a.text_field :city %> <% end %> <% end %> And my controller as follows: class ClientsController < ApplicationController before_filter :load_client , :except => [:index, :new, :create, :render_clients] def new @client = Client.new @client.addresses.build end def create @client = Client.new(params[:client]) if @client.save flash[:notice] = 'Client has been successfully added' redirect_to @client else render :action => 'new' end end The issue is that when the record is saved it gives an error stating: "Entity can't be blank" I assume it is something to do with the fact that a 'Client' and not an 'Entity' is being added. Can anyone point me in the right direction?

    Read the article

  • Agile web development with Rails 4 interface difficulties

    - by Luke Annison
    I've been following along with the examples in the book in making a online catalog and am having a couple of discouraging difficulties in Chapter 8 task C: Catalog display. I have input the code for the stylesheets as instructed but it has created a slightly skewed result as compared to what is shown in the book. Whilst minor and aesthetic in nature its a little shock to my confidence and slightly irritating when trying to carry on through the book. I have too little rep to post a pic, but heres the link: http://s11.postimage.org/3pwlzfiwj/Screen_Shot_2012_10_08_at_22_29_56.png) As you can see the boarder seems a little confused and the image at the top is covering the header text. I've been through the code time and time again but can't seem find out where I've gone wrong. Could anybody give me some clues?

    Read the article

  • jquery/javascripts not loading in ruby on rails

    - by Marco A
    I am having a very weird problem that just came up and my guess it's that it may be easy to solve, I just can't seem to figure out. in my layout/application.html.haml, I have the following: = javascript_include_tag :all Rather than RoR translating this to a lot of script-loading lines, it does the following: <script src="/beta/assets/all.js" type="text/javascript"></script> similarly, with defaults I get: <script src="/beta/assets/defaults.js" type="text/javascript"></script> What should I look for? or what I am missing? Thanks!

    Read the article

  • Failing rspec Rails Tutorial Chapter 9.3

    - by greyghost24
    I am failing 3 tests and I have found numerous examples on here and on on the internet in general but I can't seem to find where I'm going wrong. Thanks for any help. 1) User pages signup with valid information edit page Failure/Error: before { visit edit_user_path(user) } ActionView::Template::Error: undefined method `model_name' for NilClass:Class # ./app/views/users/edit.html.erb:6:in `_app_views_users_edit_html_erb___4113112884365867193_70232486166220' # ./spec/requests/user_pages_spec.rb:96:in `block (5 levels) in <top (required)>' 2) User pages signup with valid information edit page Failure/Error: before { visit edit_user_path(user) } ActionView::Template::Error: undefined method `model_name' for NilClass:Class # ./app/views/users/edit.html.erb:6:in `_app_views_users_edit_html_erb___4113112884365867193_70232486166220' # ./spec/requests/user_pages_spec.rb:96:in `block (5 levels) in <top (required)>' 3) User pages signup with valid information edit page Failure/Error: before { visit edit_user_path(user) } ActionView::Template::Error: undefined method `model_name' for NilClass:Class # ./app/views/users/edit.html.erb:6:in `_app_views_users_edit_html_erb___4113112884365867193_70232486166220' # ./spec/requests/user_pages_spec.rb:96:in `block (5 levels) in <top (required)>' Finished in 0.26515 seconds 3 examples, 3 failures Failed examples: rspec ./spec/requests/user_pages_spec.rb:100 # User pages signup with valid information edit page rspec ./spec/requests/user_pages_spec.rb:99 # User pages signup with valid information edit page rspec ./spec/requests/user_pages_spec.rb:101 # User pages signup with valid information edit page authentication_pages_spec.rb require 'spec_helper' describe "Authentication" do subject { page } describe "signin page" do before { visit signin_path } it { should have_selector('h1', text: 'Sign in') } it { should have_selector('title', text: 'Sign in') } end describe "signin" do before { visit signin_path } describe "with invalid information" do before { click_button "Sign in" } it { should have_selector('title', text: 'Sign in') } it { should have_selector('div.alert.alert-error', text: 'Invalid') } describe "after visiting another page" do before { click_link "Home" } it { should_not have_selector('div.alert.alert-error') } end end describe "with valid information" do let(:user) { FactoryGirl.create(:user) } before do fill_in "Email", with: user.email fill_in "Password", with: user.password click_button "Sign in" end it { should have_selector('title', text: user.name) } it { should have_link('Profile', href: user_path(user)) } it { should have_link('Sign out', href: signout_path) } it { should_not have_link('Sign in', href: signin_path) } describe "followed by signout" do before { click_link "Sign out" } it { should have_link('Sign in') } end end end end Here is the users_controller: class UsersController < ApplicationController def show @user = User.find(params[:id]) end def new @user = User.new end def create @user = User.new(params[:user]) if @user.save sign_in @user flash[:success] = "Welcome to the Sample App!" redirect_to @user else render 'new' end end end def edit @user = User.find(params[:id]) end edit.html.erb: <% provide(:title, "Edit user") %> <h1>Update your profile</h1> <div class="row"> <div class="span6 offset3"> <%= form_for(@user) do |f| %> <%= render 'shared/error_messages' %> <%= f.label :name %> <%= f.text_field :name %> <%= f.label :email %> <%= f.text_field :email %> <%= f.label :password %> <%= f.password_field :password %> <%= f.label :password_confirmation, "Confirm Password" %> <%= f.password_field :password_confirmation %> <%= f.submit "Save changes", class: "btn btn-large btn-primary" %> <% end %> <%= gravatar_for @user %> <a href="http://gravatar.com/emails">change</a> </div> here is the user_pages_spec: require 'spec_helper' describe "User pages" do subject { page } describe "profile page" do let(:user) { FactoryGirl.create(:user) } before { visit user_path(user) } it { should have_selector('h1', text: user.name) } it { should have_selector('title', text: user.name) } end describe "signup page" do before { visit signup_path } it { should have_selector('h1', text: 'Sign up') } it { should have_selector('title', text: full_title('Sign up')) } end describe "signup" do before { visit signup_path } describe "with invalid information" do it "should not create a user" do expect { click_button "Create my account" }.not_to change(User, :count) end describe "error messages" do before { click_button "Create my account" } it { should have_selector('title', text: 'Sign up') } it { should have_content('error') } end end describe "with valid information" do before do fill_in "Name", with: "Example User" fill_in "Email", with: "[email protected]" fill_in "Password", with: "foobar" fill_in "Confirmation", with: "foobar" end it "should create a user" do expect do click_button "Create my account" end.to change(User, :count).by(1) end describe "after saving the user" do before { click_button "Create my account" } let(:user) { User.find_by_email('[email protected]') } it { should have_selector('title', text: user.name) } it { should have_selector('div.alert.alert-success', text: 'Welcome') } it { should have_link('Sign out') } end end end describe "signup page" do before { visit signup_path } it { should have_selector('h1', text: 'Sign up') } it { should have_selector('title', text: full_title('Sign up')) } end describe "signup" do before { visit signup_path } let(:submit) { "Create my account" } describe "with invalid information" do it "should not create a user" do expect { click_button submit }.not_to change(User, :count) end end describe "with valid information" do before do fill_in "Name", with: "Example User" fill_in "Email", with: "[email protected]" fill_in "Password", with: "foobar" fill_in "Confirmation", with: "foobar" end it "should create a user" do expect { click_button submit }.to change(User, :count).by(1) end describe "edit" do let(:user) { FactoryGirl.create(:user) } before { visit edit_user_path(user) } describe "page" do it { should have_selector('h1', text: "Update your profile") } it { should have_selector('title', text: "Edit user") } it { should have_link('change', href: 'http://gravatar.com/emails') } end describe "with invalid information" do before { click_button "Save changes" } it { should have_content('error') } end end end end end edit: users_controllers.rb was formatted incorrectly. It should look like this: class UsersController < ApplicationController def show @user = User.find(params[:id]) end def new @user = User.new end def create @user = User.new(params[:user]) if @user.save sign_in @user flash[:success] = "Welcome to the Sample App!" redirect_to @user else render 'new' end end def edit @user = User.find(params[:id]) end end

    Read the article

  • Rails Active Record find(:all, :order => ) issue.

    - by CodingWithoutComments
    I seem to be unable to use :order_by for more than one column at a time. For example, I have a "Show" model with date and attending columns. If I run the following code: @shows = Show.find(:all, :order => "date") I get the following results: [#<Show id: 7, date: "2009-04-18", attending: 2>, #<Show id: 1, date: "2009-04-18", attending: 78>, #<Show id: 2, date: "2009-04-19", attending: 91>, #<Show id: 3, date: "2009-04-20", attending: 16>, #<Show id: 4, date: "2009-04-21", attending: 136>] If I run the following code: @shows = Show.find(:all, :order => "attending DESC") [#<Show id: 4, date: "2009-04-21", attending: 136>, #<Show id: 2, date: "2009-04-19", attending: 91>, #<Show id: 1, date: "2009-04-18", attending: 78>, #<Show id: 3, date: "2009-04-20", attending: 16>, #<Show id: 7, date: "2009-04-18", attending: 2>] But, if I run: @shows = Show.find(:all, :order => "date, attending DESC") OR @shows = Show.find(:all, :order => "date, attending ASC") OR @shows = Show.find(:all, :order => "date ASC, attending DESC") I get the same results as only sorting by date: [#<Show id: 7, date: "2009-04-18", attending: 2>, #<Show id: 1, date: "2009-04-18", attending: 78>, #<Show id: 2, date: "2009-04-19", attending: 91>, #<Show id: 3, date: "2009-04-20", attending: 16>, #<Show id: 4, date: "2009-04-21", attending: 136>] Where as, I want to get these results: [#<Show id: 1, date: "2009-04-18", attending: 78>, #<Show id: 7, date: "2009-04-18", attending: 2>, #<Show id: 2, date: "2009-04-19", attending: 91>, #<Show id: 3, date: "2009-04-20", attending: 16>, #<Show id: 4, date: "2009-04-21", attending: 136>] This is the query being generated from the logs: [4;35;1mUser Load (0.6ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) LIMIT 1[0m [4;36;1mShow Load (3.0ms)[0m [0;1mSELECT * FROM "shows" ORDER BY date ASC, attending DESC[0m [4;35;1mUser Load (0.6ms)[0m [0mSELECT * FROM "users" WHERE ("users"."id" = 1) [0m Finally, here is my model: create_table "shows", :force => true do |t| t.string "headliner" t.string "openers" t.string "venue" t.date "date" t.text "description" t.datetime "created_at" t.datetime "updated_at" t.decimal "price" t.time "showtime" t.integer "attending", :default => 0 t.string "time" end What am I missing? What am I doing wrong? UPDATE: Thanks for all your help, but it seems that all of you were stumped as much as I was. What solved the problem was actually switching databases. I switched from the default sqlite3 to mysql.

    Read the article

  • Rails: Best practice to store user settings?

    - by ole_berlin
    Hi, I'm wondering what the best way is to store user settings? For a web 2.0 app I want users to be able to select certain settings. At the moment is it only when to receive email notifications. The easiest way would be to just create a Model "Settings" and have a column for every setting and then have a 1-1 relationship with users. But is there a pattern to solve this better? Is it maybe better to store the info in the user table itself? Or should I use a table with "settings_name" and "settings_value" to be completely open about the type of settings stored there (without having to run any migrations when adding options)? What is your opinion? Thanks

    Read the article

  • ruby on rails - link_to() problem

    - by Oded Harth
    Hi, I made this link in order to destroy a comment :   <%= link_to 'Destroy Comment', [comment.post, comment], :confirm => 'Are you sure?', :method => :delete %> this suppose to send to the destroy action in the comments_controller. the problem is that it searches for the 'show' action, Instead of the 'destroy' action : Unknown action The action 'show' could not be found for CommentsController Do you think you know why it does that? Thanks, Oded edit: problem solved I used 'button_to'

    Read the article

  • Error using 'send_file' for ruby/rails - help appreciated

    - by user1653279
    I am trying to create a link to download a file from the file system. For this, I define the following in the "license_helper.rb" file: def license_download_link(license, link_text = nil) if link_text.blank? link_text = image_tag("download_icon.png", :border => 0, :width => 32, :height =>32, :alt => 'Download License', :title => 'Download License') end tempLicenseFile = "tempLicense.xml" File.open("#{tempLicenseFile}", 'w') do |tf| tf.puts license.data end command = "./runLicenseEncoder.bat #{tempLicenseFile}" generateEncryptedLicenseFile = `#{command}` theLicenseFile = "license.xml" link_to link_text, "license/download" end My "view" just calls this helper class: <td><%= license_download_link(license, ' ') %></td> In the 'routes.rb' file, I have defined the following: map.licensedownload "license.xml", :controller = 'licenses', :action = 'download' map.download "/licenses/download", :controller = 'licenses', :action = 'download' In the 'controller', I have 'licenses_controller.rb' which includes the following: def download theLicense = @license licenseFileName = "license.xml" send_file "#{licenseFileName}" , :type => "application/xml", :filename => "#{licenseFileName}" end However, I am unable to obtain the '@license' attribute from the database in the controller. Could someone please let me know what I am doing wrong here and why I am unable to get the value for "@license". Thanks for your time, Regards, --- AJ

    Read the article

  • Non-auto-increment rails/postgresql column

    - by Redian
    I'm trying to have a model/table with duplicate information in it. The reason for this is so that the same data can be written to the table under different users and found for each user. However, I want a quick easy way to identify which information is a duplicate of other information. I think the best way to do this would be to have an item_id of sorts that increments with each "set" of entries to the table. Is there a way to do this without including another table that stores the information without attributing it to users?

    Read the article

  • group by country with ActiveRecords in Rails

    - by Adnan
    Hello, I have a table with users: name | country | .. | UK | .. | US | .. | US | .. | UK | .. | FR | .. | FR | .. | UK | .. | UK | .. | DE | .. | DE | .. | UK | .. | CA | . . What is the most efficient way with ActiveRecords to get the list of countries in my view and for each country how many users are from, so: US 123 UK 54 DE 33 . . .

    Read the article

  • How do you deploy your Rails application?

    - by Michael Sync
    Do you upload your rail application to your host via FTP first? I'm currently using Passenger and Capistrano. If I do "cap deploy" in my local machine then I think Capistrano should upload my rail application to my host, right? Someone from my host is saying that I need to run "cap deploy" in server. I think it doesn't make sense.

    Read the article

< Previous Page | 110 111 112 113 114 115 116 117 118 119 120 121  | Next Page >