Search Results

Search found 4088 results on 164 pages for 'params keyword'.

Page 62/164 | < Previous Page | 58 59 60 61 62 63 64 65 66 67 68 69  | Next Page >

  • Lithium: Run filter after find() to format output

    - by Housni
    I wanted to specify the output of a field from within my model so I added a date key to my $_schema: models/Tags.php <?php protected $_schema = array( 'id' => array('type' => 'integer', 'key' => 'primary'), 'title' => array('type' => 'string'), 'created' => array('type' => 'integer', 'date' => 'F jS, Y - g:i a'), 'modified' => array('type' => 'integer') ); ?> I store my time as an unsigned integer in the db (output of time()). I want my base model to format any field that has the date key for output. I thought the best place to do that would be right after a find: extensions/data/Model.php <?php static::applyFilter('find', function($self, $params, $chain) { $schema = $self::schema(); $entity = $chain->next($self, $params, $chain); foreach ($schema as $field => $options) { if (array_key_exists('date', $options)) { //format as a date $params['data'][$field] = $entity->formatDate($field, $options['date']); } } return $entity; }); public function formatdate($entity, $field, $format, $timezone = 'Asia/Colombo') { $dt = new \DateTime(); $tz = new \DateTimeZone($timezone); $dt->setTimestamp($entity->$field); $dt->setTimezone($tz); return $dt->format($format); } ?> This doesn't seem to be working. When I execute a find all, this filter seems to get hit twice. The first time, $entity contains a count() of the results and only on the second hit does it contain the Records object. What am I doing wrong? How do I alter this so that simply doing <?= $tag->created; ?> in my view will format the date the way I want? This, essentially, needs to be an 'after filter', of sorts. EDIT If I can find a way to access the current model entity object (not the full namespaced path, $self contains that), I can probably solve my problem.

    Read the article

  • Get top 'n' records by report_id

    - by Skudd
    I have a simple view in my MSSQL database. It consists of the following fields: report_id INT ym VARCHAR -- YYYY-MM keyword VARCHAR(MAX) visits INT I can easily get the top 10 keyword hits with the following query: SELECT TOP 10 * FROM top_keywords WHERE ym BETWEEN '2010-05' AND '2010-05' ORDER BY visits DESC Now where it gets tricky is where I have to get the top 10 records for each report_id in the given date range (ym BETWEEN @start_date AND @end_date). How would I go about getting the top 10 for each report_id? I've stumbled across suggestions involving the use of ROW_NUMBER() and RANK(), but have been vastly unsuccessful in their implementation.

    Read the article

  • What is the best way to handle dynamic content_type in Sinatra

    - by lusis
    I'm currently doing the following but it feels "kludgy": module Sinatra module DynFormat def dform(data,ct) if ct == 'xml';return data.to_xml;end if ct == 'json';return data.to_json;end end end helpers DynFormat end My goal is to plan ahead. Right now we're only working with XML for this particular web service but we want to move over to JSON as soon as all the components in our stack support it. Here's a sample route: get '/api/people/named/:name/:format' do format = params[:format] h = {'xml' => 'text/xml','json' => 'application/json'} content_type h[format], :charset => 'utf-8' person = params[:name] salesperson = Salespeople.find(:all, :conditions => ['name LIKE ?', "%#{person}%"]) "#{dform(salesperson,format)}" end It just feels like I'm not doing it the best way possible.

    Read the article

  • How to search for a specific word in a row in MYSQL?

    - by user220755
    I have a row that has keywords in this way (keyword1, keyword2, keyword3) separated by commas as shown. When a user signs in, you know that he wants information about (keyword1, keyword3). Now, I have another table that has bunch of information related to different keywords, this table has a row called (keywords) which indicates if this information is suitable for which keyword. How do I render for the user the information he needs depending on the keywords. In other words, if the user wants information about (keyword3, keyword1) how do I go to the (information) table and find all the information that has the word (keyword1) or the word (keyword3) in the row (keyword)? Sorry if this is complicated (my explanation) but I tried my best to explain it. Thank you in advance :)

    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

  • simple search in rails

    - by Adnan
    Hi, I'm making a simple search form in rails. In my search view I have two select boxes with fixed values like: SELECT BOX 1 SELECT BOX 2 ALL, ALL, FR, FR, US, US, DE DE And I have 2 fields in my DB with country_from and country_to. So for making a simple search like from FR to US I use: @search_result = Load.find(:all, :conditions => "country_from='#{params[:country_from]}' AND country_to='#{params[:country_to]}'" ) that is fine, but I need to implement the ALL option as well, so when I make a search like from DE to ALL I get a list with all countries in country_to I image I can do it with ifs...but what would be the most efficient way to do it?

    Read the article

  • Pagination using Ajax in jquery Datatables

    - by kshtjsnghl
    I am using dataTables plugin for a table on a page I am working on. Its basically fetching rows through an ajax call and in this ajax call, I send the search params that the user selects and the page number required. I need the Next, Previous, First and Last buttons to also fire the same ajax call, but with different page numbers, as the back-end interceptor depends on the page number. This api call would return total no. of rows(say 1000) belonging for these search params and the rows with the page size( say 50). Is there any way, I can use data table to do this?

    Read the article

  • MVC4 not binding a list of basic types

    - by admanb
    I cannot, for the life of me, get this data to bind. Here's my JavaScript: var params = { 'InvItemIDs': ["188475", "188490"]}; $.post("api/Orders/OrderFromInventory?" + $.param(params)) and the Controller action: public HttpResponseMessage OrderFromInventory(IList<int> InvItemIDs) { return new HttpResponseMessage(); } I've built the query string so that it's sending: ?InvItemIDs=188475&InvItemIDs=188490 as well as ?InvItemIDs[]=188475&InvItemIDs[]=188490 and even ?InvItemIDs[0]=188475&InvItemIDs[1]=188490 and none of them are binding. InvItemIDs is always null. What am I doing wrong? EDIT: So it turns out all this is a bug (or something) in the new Web API controller code in MVC4. As soon as I moved the exact same code over to a standard controller it started working. I'm still interested if anyone has any insight as to why the Web API would break this binding.

    Read the article

  • Which reporting tool would you recommend?

    - by grady
    Hi, I have some reporting functionality in my app and I want to improve it a bit. Its only SQL in a XML file which is read by some parser. There can be some params for that SQL and when its parsed and the params are injected, it is executed against my DB (SQL Server). I want to improve that a bit so that the results look better and are more flexible. This are the most important points I need to have: subtotals layout that can change dynamically according to settings in DB (like logo, slogan) possibility to use the same report template for several customers (same fields, but different logos,colors, slogans etc.) should run from an ASP.NET application It should be as dynamic as possible. I know of Crystal Reports and the Microsoft Reporting Tool. Are there any others that might be of interest and are my above points possible at all? Thanks for some ideas and hints :-)...

    Read the article

  • Implementing an ActiveRecord before_find

    - by thaiyoshi
    I am building a search with the keywords cached in a table. Before a user-inputted keyword is looked up in the table, it is normalized. For example, some punctuation like '-' is removed and the casing is standardized. The normalized keyword is then used to find fetch the search results. I am currently handling the normalization in the controller with a before_filter. I was wondering if there was a way to do this in the model instead. Something conceptually like a "before_find" callback would work although that wouldn't make sense on for an instance level.

    Read the article

  • 1) PasswordResets emails user when requesting password reset

    - by Surge Pedroza
    I've been trying to add a password reset for users that forget their password. The users clicks on forgot password? on sign up page. Then the user types their email and clicks reset password, which creates a token and sends an email with a link to reset their password. For the most part, it was working well, and then it suddenly stopped working. When a user clicks password reset, it brings up the error message: Password cant be blank, password is too short(6 min) Ran into this error in video 275 How I Test. on 11:20 Failure/Error: click_button "Reset Password" ActiveRecord::RecordInvalid: Validation failed: Password can't be blank, Password is too short (minimum is 6 characters), Password confirmation can't be blank # ./app/models/user.rb:30:in send_password_reset' # ./app/controllers/password_resets_controller.rb:7:increate' # (eval):2:in click_button' # ./spec/requests/password_resets_spec.rb:9:inblock (2 levels) in ' Finished in 13.66 seconds 95 examples, 1 failure This is some of the code being used. user.rb # == Schema Information # # Table name: users # # id :integer not null, primary key # name :string(255) # email :string(255) # created_at :datetime not null # updated_at :datetime not null # class User < ActiveRecord::Base attr_accessible :name, :email, :password, :password_confirmation has_secure_password before_save { |user| user.email = email.downcase } before_save :create_remember_token validates :name, presence: true, length: { maximum: 50 } VALID_EMAIL_REGEX = /\A[\w+\-.]+@[a-z\d\-.]+\.[a-z]+\z/i validates :email, presence: true, format: { with: VALID_EMAIL_REGEX }, uniqueness: { case_sensitive: false } validates :password, presence: true, length: { minimum: 6 } validates :password_confirmation, presence: true def send_password_reset generate_token(:password_reset_token) self.password_reset_sent_at = Time.zone.now save! UserMailer.password_reset(self).deliver end def generate_token(column) begin self[column] = SecureRandom.urlsafe_base64 end while User.exists?(column => self[column]) end def self.search(search) if search find(:all, :conditions => ['name LIKE ?', "%#{search}%"]) else find(:all) end end private def create_remember_token self.remember_token = SecureRandom.urlsafe_base64 end end password_resets_controller.rb class PasswordResetsController < ApplicationController def new end def create user = User.find_by_email(params[:email]) user.send_password_reset redirect_to root_url, :notice => "Email sent with password reset instructions." end def edit @user = User.find_by_password_reset_token!(params[:id]) end end new.html.erb <h1>Reset Password</h1> <%= form_tag password_resets_path, :method => :post do %> <div class="field"> <%= label_tag :email %> <%= text_field_tag :email, params[:email] %> </div> <div class="actions"><%= submit_tag "Reset Password" %></div> <% end %>

    Read the article

  • Sharepoint 2010 - Managed KeyWords

    - by Audioillity
    Hi, Is it possible to import managed keywords into SharePoint 2010? Where are the keywords stored within which database? Background - I'm currently working on a migration from a legacy system into SharePoint 2010. So far everything is going well, and I can even bring across the managed meta data across along with most other data. The process I use was built for SharePoint 2007 to update Lists over SOAP. With a few manual tweaks I've managed to get the metadata to come across. To bring across either managed metadata or managed keywords I need to know the ID for the existing label/keyword. I have this for the Managed Metadata however not for the Managed Keyword. Currently I create a CSV file to be imported for managed metadata before working out the reverent GUID for the source label. Many Thanks Luke

    Read the article

  • focus() jQuery function doesn't work in Safari, but works fine on all other browsers?

    - by pMan
    I have a search text field and search button, when button is clicked with default text in text field, or null value, an alert pops up and sets focus back on search text field. This works very well on all major browsers but not in safari. I tried it even with out jquery, but didn't work. When the focus falls on search text field, I have another jQuery function, is that the problem. The code that sets focus on search text is: if (defaults.keyword == SEARCH_TIP || defaults.keyword == '') { alert(SEARCH_NULL); $('#store_search_keyword').focus(); return false; } The code on focus is: var search_dom = $('#store_search_keyword'); var search_text = search_dom.val(); search_dom.focus(function(){ if ($(this).val() === SEARCH_TIP) { $(this).val(''); } }); any help is appreciated, 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

  • Rails creating and updating 2 model records simultaneously

    - by LearnRails
    I have 2 tables product and history product table id name type price location 1 abc electronics $200 aisle1 history table id product_id status 1 1 price changed from $200 to $180 Whenever the product price or location is updated by a user by hitting the update button, 1) the changes should be automatically be reflected in the history status column without the user having to enter that manually. if the price is updated from 200 to 180 then a new history row will be created with new id and the status column will say ' price changed from $200 to $180' if the location is updated from aisle1 to aisle 2 then status displays ' loc changed from ailse1 to aisle 2' I tried to @product = Product.new(params[:product]) @history= History.new(params[:history]) if @product.save @history.new(attributes) == I am not sure of whether this approach is correct I would really appreciate if someone could tell me how the history can be automatically updated in this case.

    Read the article

  • Generated PersonController expects Authority to contain word ROLE

    - by Chip L
    I'm brand new to acegi and relatively new to Grails. I just followed the tutorial to set up a new role and a new user. Every time I saved the user (with a role checked), it saved the user information fine, but not the role associated with the user. I finally dug into the controller code that was generated, and noticed this: private void addRoles(person) { for (String key in params.keySet()) { if (key.contains('ROLE') && 'on' == params.get(key)) { Authority.findByAuthority(key).addToPeople(person) } } } So to be sure I was interpreting it correctly, I added the word ROLE to my authorties, and it worked like a charm. Am I missing something obvious, is this a bug, or.......? The examples showed simple role names like "user" or "manager".

    Read the article

  • php and SQL_CALC_FOUND_ROWS

    - by Lizard
    I am trying to add the SQL_CALC_FOUND_ROWS into a query (Please note this isn't for pagination) please note I am trying to add this to a cakePHP query the code I currently have is below: return $this->find('all', array( 'conditions' => $conditions, 'fields'=>array('SQL_CALC_FOUND_ROWS','Category.*','COUNT(`Entity`.`id`) as `entity_count`'), 'joins' => array('LEFT JOIN `entities` AS Entity ON `Entity`.`category_id` = `Category`.`id`'), 'group' => '`Category`.`id`', 'order' => $sort, 'limit'=>$params['limit'], 'offset'=>$params['start'], 'contain' => array('Domain' => array('fields' => array('title'))) )); Note the 'fields'=>array('SQL_CALC_FOUND_ROWS',' this obviously doesn't work as It tries to apply the SQL_CALC_FOUND_ROWS to the table e.g. SELECTCategory.SQL_CALC_FOUND_ROWS, Is there anyway of doing this? Any help would be greatly appreciated, thanks.

    Read the article

  • using ajax url to call function

    - by Steven Vanerp
    Hopefully I can ask this correctly cuz I know what I want it to do but can't seem to find any answers from searching. I have a func.php page where I have all my functions and I want ajax to use one function from that page. func.php function toptable() { echo"something happens in here"; } index.php <?php include 'func.php'; ?> <script type="text/javascript"> function check_username() { uname=document.getElementById("username").value; var params = "user_id="+uname; var url = "topoftable()"; $.ajax({ type: 'POST', url: url, dataType: 'html', data: params, beforeSend: function() { document.getElementById("right").innerHTML= 'checking' ; }, complete: function() { }, success: function(html) { document.getElementById("right").innerHTML= html ; } }); } </script> Make sense?

    Read the article

  • Rails nil can't be coerced into Float

    - by alex
    After adding items, attempting to view my cart leads me to this error: nil can't be coerced into Float with the math line in this method in my line_item model highlighted: def total_price product.price * quantity end line items create action def create product = Product.find(params[:product_id]) @line_item = @cart.add_product(product.id) @line_item.quantity = params[:quantity] view <div id= "text_field"><%= text_field_tag 'quantity' %> </div> <%= button_to 'Add to Cart', line_items_path(:product_id => product) %> This has held me back for a couple days. (I'm new). Thanks.

    Read the article

  • How to hide classes to external namespaces? Something like the package-protected modifier in Java

    - by devoured elysium
    In java is easy to "hide" classes from outside your package(namespace), as you can define them as package-protected. There seems to be no equivalent keyword modifier in C#. Is there any way I could mimic that behaviour in C#? I have a couple of classes that I really wouldn't like the rest of the assembly to know of. It is ok for classes in the same namespace to know of, but I'd like them to be hidden from the rest of the library/application. I know of the internal keyword, but that only hiddes classes if you try to access them from outside your assembly. That is not really my case, as I'd like to keep everything glued in just one .DLL/.EXE. Thanks

    Read the article

  • OpenId + Bort + google

    - by zakurahime
    Hi I'm new in using ruby and i wanted to implement the openid feature that came with the bort template... I used the google openid url https://www.google.com/accounts/o8/id in the sign up but it cant get the email that i used in the openid login.. here's a part of my code... its the standard code from the bort template def create logout_keeping_session! if using_open_id? authenticate_with_open_id(params[:openid_url], :return_to => open_id_create_url, :required => [:nickname, :email]) do |result, identity_url, registration| if result.successful? create_new_user(:identity_url => identity_url, :login => registration['nickname'], :email => registration['email']) else failed_creation(result.message || "Sorry, something went wrong") end end else create_new_user(params[:user]) end end i will really appreciate any help on this.. i've been stuck with this for a few days now.. thanks

    Read the article

  • NoMethodError in UsersController#create

    - by Mike DeVerna
    I'm getting stuck on an error I'm getting when signing up a new user in Michael Hart's Ruby on Rails Tutorial. I'm new to rails but I've been searching for hours and can't seem to find anything to figure out the issue. My initial thought is that it's specific to the following line: redirect_to @user This is my file for users_controller.rb #!/bin/env ruby # encoding: utf-8 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 flash[:success] = "Welcome to the Sample App!" ?????????????? redirect_to @user else render 'new' end end end This is the error message I get: NoMethodError in UsersController#create undefined method `??????????????' for # Rails.root: /Users/mikedeverna/Documents/rails_projects/sample_app Application Trace | Framework Trace | Full Trace app/controllers/users_controller.rb:18:in `create' Here is the code in my routes.rb file: SampleApp::Application.routes.draw do resources :users resources :sessions, only: [:new, :create, :destroy] root to: 'static_pages#home' match '/signup', to: 'users#new' match '/signin', to: 'sessions#new' match '/signout', to: 'sessions#destroy', via: :delete match '/help', to: 'static_pages#help' match '/about', to: 'static_pages#about' match '/contact', to: 'static_pages#contact'

    Read the article

  • dependent: :destroy is not deleting dependencies from views

    - by jxdx
    Projects have many rooms. When I delete a project from the view, the associated rooms are not deleted. Rooms also have many products which should also be deleted when a project is deleted. Project class class Project < ActiveRecord::Base belongs_to :user has_many :rooms, dependent: :destroy has_many :products, through: :rooms end Projects Controller class ProjectsController < ApplicationController def destroy @project = current_user.projects.find(params[:id]) if @project.delete redirect_to user_projects_path(@project.user) end end end Rooms Controller class RoomsController < ApplicationController def destroy @room = Room.find(params[:id]) if @room.delete redirect_to root_path end end The delete link in the projects show view. = link_to "Delete", project_room_path(room.project, room), method: :delete, data: { confirm: "Are you sure?" }, title: room.title, class: "btn btn-danger"

    Read the article

< Previous Page | 58 59 60 61 62 63 64 65 66 67 68 69  | Next Page >