Search Results

Search found 10455 results on 419 pages for 'ruby on rails 3 1'.

Page 73/419 | < Previous Page | 69 70 71 72 73 74 75 76 77 78 79 80  | Next Page >

  • There is a JavaScript error in my rails application!

    - by Small Wolf
    As the title said, I got a problem! i encountered the "RJS Error:[object error]",the code in my application is page << "#{hidden_print("#{url_for(:controller => 'tables', :action => 'dispatch', :id => id, :pop => true, :print =>true)}")} " the method hidden_print is def hidden_print(url) "window.parent.headFrame.document.all.iframe_helper.src = '#{url}';" end

    Read the article

  • Is there a way to inspect all controller variables at once in Rails?

    - by m.u.sheikh
    I am exploring an big controller method, with about 10 or so instance variables. Some of them are set in before_filter methods, and some others inside the method itself. I want to inspect them with puts, but dont want to write all of them out example: puts "var1: #{@var1.inspect}....var15: #{@var15.inspect}" Is there a generic method that will display all the instance variables with an @ sign set so far in the current method? If not, what is the next best way to inspect all of them at once without having to write all of them in a puts statement?

    Read the article

  • Using routing (?) to make GET request in Rails so ID doesn't show

    - by ale
    I have a link in one view myapp/locations that goes to myapp/statistics?id=1 (statistics for location with ID 1) which works fine but it doesn't look pretty. I think I've seen people do this sort of thing without needing the ?id=1? I could use a POST but this is not RESTful. Is there a way I can use routing to allow the user to go to myapp/statistics?id=1 but have the user see myapp/statistics? Many thanks.

    Read the article

  • Ruby using the Gosu framework: why it runs slow first time?

    - by Omega
    I'm creating a Ruby game using the Gosu framework. All good. Sometimes, when I run the game, it has some kind of slow startup, and probably it will be rather slow during the whole game. So I close it and... open it again. It is very likely that it will startup quickly and the whole game will run smoothly and fast. Why is that? What is this phenomenon? Is it faster because of some cache stored or whatever since the first run? (But why would cache be stored? If the app dies, I would expect no references at all etc...) Ruby, Windows 7.

    Read the article

  • Rails 3: Create an instance with 3 foreign keys.

    - by donald
    Hello, Having a reviews table: # Table name: reviews # # id :integer not null, primary key # wsp_id :integer # service_id :integer # user_id :integer # description :text # rating :integer # created_at :datetime # updated_at :datetime # belongs_to :wsp belongs_to :service belongs_to :user How can I create a review for a service and pass the wsp_id and user_id? Do I need to use nested routes? I am able to do @user.reviews.new(params[:review]) but I'm not being able of passing the wsp_id and the service_id. Here's my Reviews create controller. def create @review = current_user.reviews.new(params[:review]) if @review.save #Saved else #Error, not saved end end What am I doing wrong? Thank you!

    Read the article

  • [RAILS] Why is ssl_requirement clearing the Flash? (Chrome Mac)

    - by aaronrussell
    I am using ssl_requirement and since setting it up, my application's Flash messages are disappearing. I've modified the plugin slightly as accounts can optionally have a domain mapped to their account. In that case the non-ssl areas of the site should use the mapped domain, whereas the ssl areas should use the subdomain: def ensure_proper_protocol return true if ssl_allowed? if ssl_required? && !request.ssl? redirect_to "https://#{@account.subdomain}." + APP_CONF[:domain] + request.request_uri flash.keep return false elsif request.ssl? && !ssl_required? redirect_to "http://#{@account.sub_or_mapped_domain}" + request.request_uri flash.keep return false end end The application is broadly split into a website (front end) and an admin (back end). ALL of the admin area uses SSL so in the AdminController I have overwritten ssl_required? with: protected def ssl_required? return false if RAILS_ENV == "test" || RAILS_ENV == "development" true end Interestingly, Flash messages work fine in the development environment, where I am bypassing requiring SSL, but in my production environment where SSL is required, all Flash are gone. Any ideas? EDIT I've done some further testing and can add that this problem is ONLY occurring in Chrome on the Mac. Other Mac browsers and Chrome on windows are displaying the Flash messages as expected. This may be a bug with Chrome on the Mac then...?

    Read the article

  • How do I check the Database type in a Rails Migration?

    - by Shaun F
    I have the following migration and I want to be able to check if the current database related to the environment is a mysql database. If it's mysql then I want to execute the SQL that is specific to the database. How do I go about this? class AddUsersFb < ActiveRecord::Migration def self.up add_column :users, :fb_user_id, :integer add_column :users, :email_hash, :string #if mysql #execute("alter table users modify fb_user_id bigint") end def self.down remove_column :users, :fb_user_id remove_column :users, :email_hash end end

    Read the article

  • Rails 2.3.5: How does one add an error when it doesn't make sense to put it in a validation?

    - by randombits
    I recently was trying to add errors.add_to_base code in the middle of some model logic and was wondering why it wasn't showing up in my view that was iterating over all errors. I then ran across this e-mail which explains why: http://groups.google.com/group/rubyonrails-talk/browse_thread/thread/e045ec1dead1ff06?pli=1 The question is then, how does one add errors with add_to_base if it doesn't make sense to put them into a validate method? I have some complex logic. The model needs to talk to a has_many relationship which has its own relationships that go through a myriad of conditionals to figure out if a request makes sense. It's nothing that can be tied to a validate method easily. How does one add errors then accordingly?

    Read the article

  • how to tell bulider to not to escape values

    - by dorelal
    ruby-1.8.7-p249 > xml = Builder::XmlMarkup.new => <inspect/> ruby-1.8.7-p249 > xml.foo '<b>wow</b>' => "<inspect/><foo>&lt;b&gt;wow&lt;/b&gt;</foo>" ruby-1.8.7-p249 > Builder is escaping the content and is converting the b tag into escaped value . How do I tell builder to no to escape it. I am using ruby 1.8.7 .

    Read the article

  • Ruby on Rail - Format for fetching and displaying Dymanic drop down

    - by Ruby
    Hi, I have 3 tables : Student , Subject and Score Every student can add 3 Subjects (Physics, Mathematics and Chemistry) marks. The combination of (student_id + subject_id) is added to Score table. i.e., capturing that sudent '1' has added 'Mathematics' marks with the actual score (say 0-100 range) student id : subjectid Score 1 Mathematics 95 The Add page of Score has a "subject" drop down. which is displayed from "subject" table. When the student wants to add the 2nd subject marks, in the add page, he should not be displayed the previoys added subject in the drop down. Can any1 tell me how to do this?

    Read the article

  • What is wrong with my logic in a rails hash?

    - by stevenheidel
    I have a setting in environment/production.rb of HEROKU = true This should change my has_attachment has to use s3 instead of the file system, but it doesn't. What's wrong with my logic? has_attachment :content_type => :image, :storage => ($HEROKU ? :s3 : :file_system), ... Thanks!

    Read the article

  • How to show specific link to user that's signed in and on specific page in rails?

    - by sevens
    I have the following code for part of my navigation: <% if user_signed_in? %> <li><%= link_to 'Edit Profile', edit_profile_path(current_user.profile) %></li> <li><%= link_to 'Edit Account', edit_user_registration_path %></li> <% elsif user_signed_in? and params[:controller] == 'profiles#edit' %> <li><%= link_to 'View Profile', profile_path(current_user.profile) %></li> <li><%= link_to 'Edit Account', edit_user_registration_path %></li> <% else %> <li><%= link_to 'Sign up', new_user_registration_path %></li> <% end %> I want different links to show depending on where the "user_signed_in" is. However, my <% elsif user_signed_in? and params[:controller] == 'profiles#edit' %> doesn't seem to be working. What am I doing wrong?

    Read the article

  • Checking if the email had been already taken in the following if statement (Rails)?

    - by alexchenco
    I have the following action: users.rb: def omniauth_create auth = request.env["omniauth.auth"] user = User.from_omniauth(env["omniauth.auth"]) unless user.email.blank? if user.id.nil? # Save the user since he hasn't been created yet user.save! end sign_in user redirect_back_or user else # Send user to a form to fill his email #session[:omniauth] = request.env['omniauth.auth'].except('extra') redirect_to(enter_email_path(oprovider: user.provider, ouid: user.uid, oname: user.name, opassword: user.password, opassword_confirmation: user.password)) end end It does the following: If the user's email is not blank, sign him in, and redirect him to his profile (and save him if his id is nil. In other words, if he hasn't been created yet). If the user's email is blank, send him to enter_email_path (where the user can enter his email). Now I want to add another if statement that flashes an error if the email had been already taken, and redirects the user to the root_path I'm not very sure how to do this, Any suggestions? (and where to put that if statement?)

    Read the article

  • Rails - Rendering a Partial without having to use "_" in front of the filename?

    - by bluedevil2k
    How do I render a partial without having to supply the "_" in front of the file name? Is there a parameter I can call to not use it? This problem popped up using RABL and Backbone - using RABL requires me to have a file in my views like "index.json.rabl". But, when I use embed the JSON right on the page load (as is usual with Backbone), I'm required to call the file "index.json.rabl". These 2 files are the exact same thing, just required to have different names. I'm looking to use just 1 file, "index.json.rabl" and force the render() function to look for that file name, without the "".

    Read the article

  • how can I cache a partial retrieved through link_to_remote in rails?

    - by Angela
    I use link_to_remote to pull the dynamic contents of a partial onto the page. It's basically a long row from a database of "todo's" for the day. So as the person goes through and checks them off, I want to show the updated list with a line through those that are finished. Currently, I end up needing to click on the link_to_remote again after an item is ticked off, but would like it to redirect back to the "cached" page of to-do's but with the one item lined through. How do I do that? Here is the main view: <% @campaigns.each do |campaign| %> <!--link_to_remote(name, options = {}, html_options = nil)--> <tr><td> <%= link_to_remote(campaign.name, :update => "campaign_todo", :url => {:action => "campaign_todo", :id => campaign.id } ) %> </td></tr> <% end %> </table> <div id="campaign_todo"> </div> I'd like when the New/Create actions are done to go back to the page that redirected it there.

    Read the article

  • Rails: saving a string on an object -- syntax problem?

    - by Veep
    Hey there, I am trying to write a simple function to clean a filename string and update the object. When I save a test string it works, but when I try to save the string variable I've created, nothing happens. But when I return the string, the output seems to be correct! What am I missing? def clean_filename clean_name = filename clean_name.gsub! /^.*(\\|\/)/, '' clean_name.gsub! /[^A-Za-z0-9\.\-]/, '_' clean_name.gsub!(/\_+/, ' ') #update_attribute(:filename, "test") #<-- correctly sets filename to test #update_attribute(:filename, clean_name) #<-- no effect????? WTF #return clean_name <-- seems to returns the correct string end Thank you very much.

    Read the article

  • How can I defend Ruby on Rails against customers' not technical opinion?

    - by okeen
    My customer, a translations business owner, just told me that he has been reading about Ruby on Rails and told me that "there are more PHP guys around there" and "it seems the community prefers it". What would you, as software engineer and freelancer, say to the customer to achieve these goals: Sell Make him see that the technology is my expert decision and Rails is as good or better than PHP (+ whatever framework) for this particular project. UPDATE: Thank you all for the suggestions! Tomorrow I've got another meeting with him, let's see how it goes, I will update again :) UPDATE 2: Finally I told him to read this thread and the result has been fantastic: He gave me the project and we are going to start right now. Thank you all for the help, you have free beer in my charge if we see someday :) BTW: I learned the lesson: be as transparent as possible, because if you believe in yourself and your work, there is no question compromising enough to beat you. regards

    Read the article

  • In Rails models; for symbols get automatically converted to YAML when saving to DB. What is the corr

    - by Ram
    In my model example Game, has a status column. But I usually set status by using symbols. Example self.status = :active MATCH_STATUS = { :betting_on => "Betting is on", :home_team_won => "Home team has won", :visiting_team_won => "Visiting team has one", :game_tie => "Game is tied" }.freeze def viewable_status MATCH_STATUS[self.status] end I use the above Map to switch between viewable status and viceversa. However when the data gets saved to db, ActiveRecord appends "--- " to each status. So when I retrieve back the status is screwed. What should be the correct approach?

    Read the article

  • Rails - Always have to check exists, and then value?

    - by Jason B
    I am checking to see if a value in a related table exists quite often in my view, in this case, expenses have approvals. If they have not been submitted, then there is no record of them in the approvals table. I am ending up with some really awkward code <% if !expense_item.expense_approval || expense_item.expense_approval.approval_status == 0 %> Is there a way to do an if statement on a value, without having to check if it exists first? Or some default way to set it nil?

    Read the article

  • How do you deal with breaking changes in a Rails migration?

    - by Adam Lassek
    Let's say I'm starting out with this model: class Location < ActiveRecord::Base attr_accessible :company_name, :location_name end Now I want to refactor one of the values into an associated model. class CreateCompanies < ActiveRecord::Migration def self.up create_table :companies do |t| t.string :name, :null => false t.timestamps end add_column :locations, :company_id, :integer, :null => false end def self.down drop_table :companies remove_column :locations, :company_id end end class Location < ActiveRecord::Base attr_accessible :location_name belongs_to :company end class Company < ActiveRecord::Base has_many :locations end This all works fine during development, since I'm doing everything a step at a time; but if I try deploying this to my staging environment, I run into trouble. The problem is that since my code has already changed to reflect the migration, it causes the environment to crash when it attempts to run the migration. Has anyone else dealt with this problem? Am I resigned to splitting my deployment up into multiple steps?

    Read the article

< Previous Page | 69 70 71 72 73 74 75 76 77 78 79 80  | Next Page >